I have a couple of questions on SRIDs in GeoDjango that I'm hoping someone can shed some light on.
Question 1:
Lets assume that I create a custom SRS and add it to PostGIS' spatial_ref_sys table something similar to:
cursor.execute("""INSERT into spatial_ref_sys (srid, auth_name, auth_srid, proj4text)
VALUES ( 96630, 'sr-org', 6630, '+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs ')""")
I have no problem using that SRID on geometry fields (perhaps only because they are unmanaged):
class Units(models.Model):
year = models.IntegerField(blank=True, null=True)
unit_type = models.CharField(max_length=40, blank=True, null=True)
metadata = JSONField()
source = models.CharField(max_length=40, blank=True, null=True)
source_id = models.CharField(max_length=40, blank=True, null=True)
geom = models.MultiPolygonField(srid=96630, blank=True, null=True)
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
class Meta:
managed = False
db_table = 'units'
verbose_name = "Unit"
Later on when I try to take WGS84 Lat/Long coordinates from a form and transform it to my SRID 96630 I get an SRSException similar to the following:
GDAL_ERROR 6: EPSG PCS/GCS code 96630 not found in EPSG support files. Is this a valid
EPSG coordinate system?
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Users\jzmiller1\VirtualEnvs\GeoDjangox64\lib\site-packages\django\contrib\gis\geos\geometry.py", line 534, in transform
g = gdal.OGRGeometry(self.wkb, srid)
File "C:\Users\jzmiller1\VirtualEnvs\GeoDjangox64\lib\site-packages\django\contrib\gis\gdal\geometries.py", line 117, in __init__
self.srs = srs
File "C:\Users\jzmiller1\VirtualEnvs\GeoDjangox64\lib\site-packages\django\contrib\gis\gdal\geometries.py", line 273, in _set_srs
sr = SpatialReference(srs)
File "C:\Users\jzmiller1\VirtualEnvs\GeoDjangox64\lib\site-packages\django\contrib\gis\gdal\srs.py", line 95, in __init__
self.import_epsg(srs_input)
File "C:\Users\jzmiller1\VirtualEnvs\GeoDjangox64\lib\site-packages\django\contrib\gis\gdal\srs.py", line 288, in import_epsg
capi.from_epsg(self.ptr, epsg)
File "C:\Users\jzmiller1\VirtualEnvs\GeoDjangox64\lib\site-packages\django\contrib\gis\gdal\prototypes\errcheck.py", line 119, in check_errcode
check_err(result, cpl=cpl)
File "C:\Users\jzmiller1\VirtualEnvs\GeoDjangox64\lib\site-packages\django\contrib\gis\gdal\error.py", line 72, in check_err
raise e(msg)
SRSException: Unsupported SRS.
Can I somehow add my custom SRIDs to the GFAL EPSG support files or would that be a bad thing to do? Could I specify somewhere at the GeoDjango level that transformations should be do at the PostGIS level somehow?
Question 2:
Is is possible to create a geometry column with an unspecified SRID and store geometries with an SRID on a per row basis?