Re: How transform specific geometry column using Django GIS GeoQuerySet

95 views
Skip to first unread message
Message has been deleted
Message has been deleted

Alex Mandel

unread,
Mar 26, 2014, 8:40:44 PM3/26/14
to django...@googlegroups.com
On 03/26/2014 06:28 AM, Shoaib Ijaz wrote:
> Sorry i mistype queries
>
> Network.objects.transform(srid=3857).values('geometry', 'bbox')
>>
>> SELECT ST_Transform("tbl_network"."geometry", 3857), "tbl_network"."bbox" FROM "tbl_network"
>>
>> Network.objects.transform(srid=3857).values('bbox')
>>
>> SELECT "tbl_network"."bbox" FROM "tbl_network"
>>

You might get more responses on the GeoDjango mailing list:
geod...@googlegroups.com

I think you syntax might be wrong.
https://docs.djangoproject.com/en/dev/ref/contrib/gis/gdal/#coordtransform

But since your mixing django code and SQL code it's hard to tell what
your doing.

Thanks,
Alex

Message has been deleted
Message has been deleted

Alex Mandel

unread,
Mar 27, 2014, 2:42:40 PM3/27/14
to django...@googlegroups.com
On 03/27/2014 04:53 AM, Shoaib Ijaz wrote:
>
>>
>> I am doing sql queries in django, the queries that i mentioned above are
>> print queries of django
>
>
> Network.objects.transform(srid=3857).values('geometry', 'bbox')
>
> *This is printed SQL query output of above django query *
>
> SELECT ST_Transform("tbl_network"."geometry", 3857), "tbl_network"."bbox" FROM "tbl_network"
>
> Network.objects.transform(srid=3857).values('bbox')
>
> *This is printed SQL query output of above django query *
>
> SELECT "tbl_network"."bbox" FROM "tbl_network"
>
>

I see so the 1st query works and the 2nd one fails to do the transform.
I think the problem may be related to you having 2 geometry columns in
the same Postgis table.

Are both of them listed in the geometry_columns view of Postgis.
Typically only 1 can be the default. In this case geometry, so
Geodjango/Postgis is recognizing it as a spatial column. But when it
get's to bbox it doesn't recognize it and doesn't know what the FROM
(current) srid is so a Transform wouldn't work.

One option would be to return the data and then transform it once you
have the spatial objects into python variables.

Thanks,
Alex

Shoaib Ijaz

unread,
Mar 28, 2014, 6:25:16 AM3/28/14
to django...@googlegroups.com, te...@wildintellect.com
Can you elaborate following statement, i am at beginner level in django what why i cannot understand your reply

   One option would be to return the data and then transform it once you  have the spatial objects into python variables.  

   Thank you
 
Reply all
Reply to author
Forward
0 new messages