Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6685407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:03:15+00:00 2026-05-26T05:03:15+00:00

I am building a system which lets users upload shapefiles. It then converts those

  • 0

I am building a system which lets users upload shapefiles. It then converts those shapefiles to PostGIS using shp2pgsql. This command requires the SRS ID in form of an EPSG code.

So I need a ruby gem that can read the shapefile’s *.prj file (which contains the projection/spatial reference system encoded as WKT) and return a corresponding SRS ID.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:03:15+00:00Added an answer on May 26, 2026 at 5:03 am

    I’m not sure how Ruby bindings work to GDAL, but OSR (part of GDAL) can extract either the projection WKT (text) or the SRID (integer).

    See this gis.SE answer for a solution with Python/GDAL/OSR.

    Update: It turns out the Ruby bindings work nicely as expected. To get you going, try this code:

    require 'gdal/osr'
    
    prj_fname = 'myfile.prj'
    prj = File.open( prj_fname )
    
    # Import the WKT from the PRJ file
    srs = Gdal::Osr::SpatialReference.new()
    srs.import_from_wkt( prj.read )
    
    # Various exports
    puts srs.export_to_wkt
    
    srs.auto_identify_epsg
    puts srs.get_authority_name(nil)
    puts srs.get_authority_code(nil)
    

    If you need some other aspect of the projection, explore the available public methods:

    srs.public_methods.sort
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are in the process of building a system which allows users to upload
I'm building a with-source system which I am giving out on the 'net for
I'm building a project that uses the JVCL plugin system, which relies on runtime
I am building a multithreaded system that works like this: While there are entities:
I'm building a LMS system using Sharepoint (WSS 3.0) with the Sharepoint Learning Kit
I am building a EC system for a client, this client is selling second
I'm building a CLI survey app in Java that lets users answer multiple-choice questions.
I'm building a system which can create forms during runtime. System is written for
I am building a system in which the user can build thre own navigation
If I'm building a PHP system which I expect to port to many different

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.