UDST / spandex

Spatial Analysis and Data Extraction
http://nbviewer.ipython.org/github/synthicity/user_meeting_2014/blob/gh-pages/spandex/spandex_demo.ipynb
BSD 3-Clause "New" or "Revised" License
22 stars 7 forks source link

Support custom projections #41

Closed daradib closed 10 years ago

daradib commented 10 years ago

Discussed with Eddie. Agreed to implement after working on higher priorities.

---------- Forwarded message ---------- From: Dara Adib Date: Mon, Sep 29, 2014 at 4:50 PM Subject: Re: North Carolina sample shp To: Conor Henley Cc: Eddie Janowicz, Fletcher Foti

[...]

We want to figure out how to deal with non-standard ESRI projections (SRIDs). Current versions of PostGIS only ship with EPSG codes in the spatial_ref_sys table. The prj2epsg API that we use to find SRIDs (if GDAL fails to find an SRID, which it usually does for anything other than WGS84) only matches to EPSG codes.

Here are some non-standard ESRI projections: http://spatialreference.org/ref/esri/ http://svn.osgeo.org/gdal/trunk/gdal/data/esri_extra.wkt

There are some ways to populate spatial_ref_sys with these extra projections: http://community.actian.com/wiki/Spatial_ref_sys https://gis.stackexchange.com/questions/95831/how-can-i-get-proj4text-from-srtext http://suite.opengeo.org/opengeo-docs/dataadmin/pgBasics/projections.html

spatial_ref_sys defines projections with two columns, srtext (well-known text) and proj4text (PROJ.4), which is used for reprojections. The prj file shipped with the shapefile includes srtext, but not proj4text.

OGR/GDAL can apparently determine the proj4text from the srtext in the prj file.

$ gdalsrsinfo pittzone.prj

PROJ.4 : '+proj=lcc +lat_1=34.33333333333334 +lat_2=36.16666666666666
+lat_0=33.75 +lon_0=-79 +x_0=609601.2199999997 +y_0=0 +datum=NAD83
+units=us-ft +no_defs '

OGC WKT :
PROJCS["NAD_1983_StatePlane_North_Carolina_FIPS_3200_Feet",
    GEOGCS["GCS_North_American_1983",
        DATUM["North_American_Datum_1983",
            SPHEROID["GRS_1980",6378137.0,298.257222101]],
        PRIMEM["Greenwich",0.0],
        UNIT["Degree",0.0174532925199433]],
    PROJECTION["Lambert_Conformal_Conic_2SP"],
    PARAMETER["False_Easting",2000000.002616666],
    PARAMETER["False_Northing",0.0],
    PARAMETER["Central_Meridian",-79.0],
    PARAMETER["Standard_Parallel_1",34.33333333333334],
    PARAMETER["Standard_Parallel_2",36.16666666666666],
    PARAMETER["Latitude_Of_Origin",33.75],
    UNIT["Foot_US",0.3048006096012192]]

I think QGIS does something similar when it defines custom projections for shapefiles that don't use standard ones: http://docs.qgis.org/2.2/en/docs/user_manual/working_with_projections/working_with_projections.html

Perhaps when loading shapefiles with unrecognized SRIDs, we should define a custom projection, so that we can load and reproject. Thoughts?

Alternatively, we can preload some ESRI projections, but I don't like this solution because it doesn't cover all possible custom projections and requires specifying the SRID when loading the shapefile (since prj2epsg doesn't detect it).

daradib commented 10 years ago

Done in #43 . Closing.