#36001: error GDAL_ERROR 1: b'PROJ: proj_create_from_database: crs not found' 
with
custom CRS in spatial_ref_sys
-------------------------------------+-------------------------------------
     Reporter:  Alex                 |                     Type:  Bug
       Status:  new                  |                Component:  GIS
      Version:  4.2                  |                 Severity:  Normal
     Keywords:  gdal, proj4,         |             Triage Stage:
  postgis                            |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
 Hi
 situation with custom CRS in geodjango.

 context: Debian GNU/Linux 12 (bookworm), Postgresql 16.6, Python 3.11.2,
 Postgis 3.4.2, GDAL 3.6.2, PROJ 9.1.1, Django 4.2.11

 Objects with geometry in DB creates with no problem with this class
 {{{
 from django.contrib.gis.db import models

 class Location(models.Model):
    ...
     c_geom = models.GeometryCollectionField(srid=300001)
    ...
 }}}
 gdalsrsinfo  works as expected
 {{{
 gdalsrsinfo 'USER:300001'
 PROJ.4 : +proj=tmerc ...
 }}}
 projinfo also works fine
 {{{
 projinfo 'USER:300001'
 PROJ.4 : +proj=tmerc ...
 }}}
 python manage.py shell `is correct`
 {{{
 from osgeo import osr
 sk = osr.SpatialReference()
 sk.SetFromUserInput('USER:300001')
 0
 print(sk)
 PROJCS...
 }}}

 , but app always throws errors when fetch and create objects

 {{{
 def create(self, validated_data):
         if "SRID=300001;" in str(self.validated_data["geom"]):
             logger.info("*"*60)
             logger.info(f"validated_data geom with USER:300001:
 {self.validated_data['geom']}")
             logger.info(f"geom srid: {self.validated_data['geom'].srid}")
             from osgeo import osr
             sk = osr.SpatialReference()
             sk.SetFromUserInput('USER:300001') # <- here same error:
 GDAL_ERROR 1: b'PROJ: proj_create_from_database: crs not found'
             logger.info(f"SpatialReference: {sk}")
             logger.info("*"*60)
 }}}

 error.log
 {{{
 ************************************************************
 validated_data geom with USER:300001: SRID=300001;GEOMETRYCOLLECTION Z
 (POINT Z (83721.138 59266.787 101.09))
 geom srid: 300001
 GDAL_ERROR 1: b'PROJ: proj_create_from_database: crs not found'
 SpatialReference:
 ************************************************************
 GDAL_ERROR 1: b'PROJ: proj_create_from_database: crs not found'
 GDAL_ERROR 1: b'PROJ: proj_create_from_database: crs not found'
 ...
 }}}
 if request one object via api, Django send 8 email with this error. odd
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36001>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/01070193b67cfc6b-bc45c8a7-5d8b-487a-a2c9-a0743d3379ff-000000%40eu-central-1.amazonses.com.

Reply via email to