Re: Confused about GeoDjango and PostGIS
I am having trouble converting latitude and longitude. Both are in double precision in the table. So, I am doing this UPDATE my_table SET geom = ST_PointFromText('POINT(' || longitude ||' '|| latitude ||')', 4326) But, when I do this SELECT ST_PointFromText(geom ) FROM my_table I am getting an error ERROR: parse error - invalid geometry HINT: "010120E610D" <-- parse error at position 19 within geometry CONTEXT: SQL function "st_pointfromtext" statement 1 thanks On Apr 26, 9:57 am, Jani Tiainen wrote: > 25.4.2012 19:17, vishy kirjoitti: > > > Hi, > > > I need to do spatial queries like find places within 5 miles of a > > location given in latitude and longitude. So, I am thinking of > > exploring PostGIS and GeoDjango. I have installed both. Now, I already > > have a database which has a table for places with latitude and > > longitude. Can I enable this db to use postgis and add column to this > > table? Or, do I have to create a separate spatial db, create a table > > with a column of geometry type and import data into that table (from > > places table).? If I can use the existing database, how do I enable it > > to use PostGIS? > > It depends on your environment but basic workflow is same is in *nix > instructions. And it's not even hard. : > > createdb yourdatabase > createlang plpgsql yourdatabase > psql -d yourdatabase -f postgis.sql > psql -d yourdatabase -f postgis_comments.sql > psql -d yourdatabase -f spatial_ref_sys.sql > > Of course in your case you can skip creation of database. Just create > language and install postgis stuff. > > After that you need to make sure that your database user has access to > geometry_columns and spatial_ref_sys tables. > > Add new column (For PostGIS 1.5.x, newer postgis has simpler alternative > syntax): > > SELECT AddGeometryColumn('my_table', 'my_geom', 4326, 'POINT', 2) > > And after that just update new geometry column: > update my_table set my_geom = GeomFromText('POINT(' + x + ' ' + y +')', > 4326) > > And don't forget to commit. If you have lot's of geometries (1M+) you > probably want to drop out spatial index and recreate it afterwards. > Otherwise building index takes just long time. > > -- > Jani Tiainen > > - Well planned is half done and a half done has been sufficient before... -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Confused about GeoDjango and PostGIS
thanks. This is what I have done. On Apr 26, 9:57 am, Jani Tiainen wrote: > 25.4.2012 19:17, vishy kirjoitti: > > > Hi, > > > I need to do spatial queries like find places within 5 miles of a > > location given in latitude and longitude. So, I am thinking of > > exploring PostGIS and GeoDjango. I have installed both. Now, I already > > have a database which has a table for places with latitude and > > longitude. Can I enable this db to use postgis and add column to this > > table? Or, do I have to create a separate spatial db, create a table > > with a column of geometry type and import data into that table (from > > places table).? If I can use the existing database, how do I enable it > > to use PostGIS? > > It depends on your environment but basic workflow is same is in *nix > instructions. And it's not even hard. : > > createdb yourdatabase > createlang plpgsql yourdatabase > psql -d yourdatabase -f postgis.sql > psql -d yourdatabase -f postgis_comments.sql > psql -d yourdatabase -f spatial_ref_sys.sql > > Of course in your case you can skip creation of database. Just create > language and install postgis stuff. > > After that you need to make sure that your database user has access to > geometry_columns and spatial_ref_sys tables. > > Add new column (For PostGIS 1.5.x, newer postgis has simpler alternative > syntax): > > SELECT AddGeometryColumn('my_table', 'my_geom', 4326, 'POINT', 2) > > And after that just update new geometry column: > update my_table set my_geom = GeomFromText('POINT(' + x + ' ' + y +')', > 4326) > > And don't forget to commit. If you have lot's of geometries (1M+) you > probably want to drop out spatial index and recreate it afterwards. > Otherwise building index takes just long time. > > -- > Jani Tiainen > > - Well planned is half done and a half done has been sufficient before... -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Confused about GeoDjango and PostGIS
25.4.2012 19:17, vishy kirjoitti: Hi, I need to do spatial queries like find places within 5 miles of a location given in latitude and longitude. So, I am thinking of exploring PostGIS and GeoDjango. I have installed both. Now, I already have a database which has a table for places with latitude and longitude. Can I enable this db to use postgis and add column to this table? Or, do I have to create a separate spatial db, create a table with a column of geometry type and import data into that table (from places table).? If I can use the existing database, how do I enable it to use PostGIS? It depends on your environment but basic workflow is same is in *nix instructions. And it's not even hard. : createdb yourdatabase createlang plpgsql yourdatabase psql -d yourdatabase -f postgis.sql psql -d yourdatabase -f postgis_comments.sql psql -d yourdatabase -f spatial_ref_sys.sql Of course in your case you can skip creation of database. Just create language and install postgis stuff. After that you need to make sure that your database user has access to geometry_columns and spatial_ref_sys tables. Add new column (For PostGIS 1.5.x, newer postgis has simpler alternative syntax): SELECT AddGeometryColumn('my_table', 'my_geom', 4326, 'POINT', 2) And after that just update new geometry column: update my_table set my_geom = GeomFromText('POINT(' + x + ' ' + y +')', 4326) And don't forget to commit. If you have lot's of geometries (1M+) you probably want to drop out spatial index and recreate it afterwards. Otherwise building index takes just long time. -- Jani Tiainen - Well planned is half done and a half done has been sufficient before... -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Confused about GeoDjango and PostGIS
Yes, I just ran the 2 scripts in my current database - spatial_ref_sys.sql and postgis.sql. Seems to work. I am able to define a geometry column in my current existing table. On Apr 25, 11:03 pm, George Silva wrote: > Yes it can, as long PostGIS is installed. > > > > > > > > > > On Wed, Apr 25, 2012 at 2:37 PM, vishy wrote: > > So, the existing database cannot be used as a postgis db? > > > On Apr 25, 9:21 pm, Jeff Heard wrote: > > > Create a new spatial database and import the data. That's by far your > > > easiest option. You'll need to create a POINT column (look at the > > PostGIS > > > doc on how to add spatial columns) and then add rows either using the ORM > > > or with a spatial query including something like this as part of the > > insert: > > > > GeomFromText('POINT(' + x + ' ' + y + ')', 4326) > > > > where 4326 is the spatial reference system for longitude/latitude. > > > > On Wed, Apr 25, 2012 at 11:17 AM, vishy wrote: > > > > Hi, > > > > > I need to do spatial queries like find places within 5 miles of a > > > > location given in latitude and longitude. So, I am thinking of > > > > exploring PostGIS and GeoDjango. I have installed both. Now, I already > > > > have a database which has a table for places with latitude and > > > > longitude. Can I enable this db to use postgis and add column to this > > > > table? Or, do I have to create a separate spatial db, create a table > > > > with a column of geometry type and import data into that table (from > > > > places table).? If I can use the existing database, how do I enable it > > > > to use PostGIS? > > > > > -- > > > > You received this message because you are subscribed to the Google > > Groups > > > > "Django users" group. > > > > To post to this group, send email to django-users@googlegroups.com. > > > > To unsubscribe from this group, send email to > > > > django-users+unsubscr...@googlegroups.com. > > > > For more options, visit this group at > > > >http://groups.google.com/group/django-users?hl=en. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-users@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group at > >http://groups.google.com/group/django-users?hl=en. > > -- > George R. C. Silva > > Desenvolvimento em > GIShttp://geoprocessamento.nethttp://blog.geoprocessamento.net -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Confused about GeoDjango and PostGIS
thanks On Apr 25, 11:07 pm, Jeff Heard wrote: > It can. I just usually consider it easier to create a new one > On Apr 25, 2012 1:38 PM, "vishy" wrote: > > > > > > > > > So, the existing database cannot be used as a postgis db? > > > On Apr 25, 9:21 pm, Jeff Heard wrote: > > > Create a new spatial database and import the data. That's by far your > > > easiest option. You'll need to create a POINT column (look at the > > PostGIS > > > doc on how to add spatial columns) and then add rows either using the ORM > > > or with a spatial query including something like this as part of the > > insert: > > > > GeomFromText('POINT(' + x + ' ' + y + ')', 4326) > > > > where 4326 is the spatial reference system for longitude/latitude. > > > > On Wed, Apr 25, 2012 at 11:17 AM, vishy wrote: > > > > Hi, > > > > > I need to do spatial queries like find places within 5 miles of a > > > > location given in latitude and longitude. So, I am thinking of > > > > exploring PostGIS and GeoDjango. I have installed both. Now, I already > > > > have a database which has a table for places with latitude and > > > > longitude. Can I enable this db to use postgis and add column to this > > > > table? Or, do I have to create a separate spatial db, create a table > > > > with a column of geometry type and import data into that table (from > > > > places table).? If I can use the existing database, how do I enable it > > > > to use PostGIS? > > > > > -- > > > > You received this message because you are subscribed to the Google > > Groups > > > > "Django users" group. > > > > To post to this group, send email to django-users@googlegroups.com. > > > > To unsubscribe from this group, send email to > > > > django-users+unsubscr...@googlegroups.com. > > > > For more options, visit this group at > > > >http://groups.google.com/group/django-users?hl=en. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-users@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group at > >http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Confused about GeoDjango and PostGIS
Thanks. On Apr 25, 11:07 pm, Jeff Heard wrote: > It can. I just usually consider it easier to create a new one > On Apr 25, 2012 1:38 PM, "vishy" wrote: > > > > > > > > > So, the existing database cannot be used as a postgis db? > > > On Apr 25, 9:21 pm, Jeff Heard wrote: > > > Create a new spatial database and import the data. That's by far your > > > easiest option. You'll need to create a POINT column (look at the > > PostGIS > > > doc on how to add spatial columns) and then add rows either using the ORM > > > or with a spatial query including something like this as part of the > > insert: > > > > GeomFromText('POINT(' + x + ' ' + y + ')', 4326) > > > > where 4326 is the spatial reference system for longitude/latitude. > > > > On Wed, Apr 25, 2012 at 11:17 AM, vishy wrote: > > > > Hi, > > > > > I need to do spatial queries like find places within 5 miles of a > > > > location given in latitude and longitude. So, I am thinking of > > > > exploring PostGIS and GeoDjango. I have installed both. Now, I already > > > > have a database which has a table for places with latitude and > > > > longitude. Can I enable this db to use postgis and add column to this > > > > table? Or, do I have to create a separate spatial db, create a table > > > > with a column of geometry type and import data into that table (from > > > > places table).? If I can use the existing database, how do I enable it > > > > to use PostGIS? > > > > > -- > > > > You received this message because you are subscribed to the Google > > Groups > > > > "Django users" group. > > > > To post to this group, send email to django-users@googlegroups.com. > > > > To unsubscribe from this group, send email to > > > > django-users+unsubscr...@googlegroups.com. > > > > For more options, visit this group at > > > >http://groups.google.com/group/django-users?hl=en. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-users@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group at > >http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Confused about GeoDjango and PostGIS
It can. I just usually consider it easier to create a new one On Apr 25, 2012 1:38 PM, "vishy" wrote: > So, the existing database cannot be used as a postgis db? > > On Apr 25, 9:21 pm, Jeff Heard wrote: > > Create a new spatial database and import the data. That's by far your > > easiest option. You'll need to create a POINT column (look at the > PostGIS > > doc on how to add spatial columns) and then add rows either using the ORM > > or with a spatial query including something like this as part of the > insert: > > > > GeomFromText('POINT(' + x + ' ' + y + ')', 4326) > > > > where 4326 is the spatial reference system for longitude/latitude. > > > > > > > > > > > > > > > > On Wed, Apr 25, 2012 at 11:17 AM, vishy wrote: > > > Hi, > > > > > I need to do spatial queries like find places within 5 miles of a > > > location given in latitude and longitude. So, I am thinking of > > > exploring PostGIS and GeoDjango. I have installed both. Now, I already > > > have a database which has a table for places with latitude and > > > longitude. Can I enable this db to use postgis and add column to this > > > table? Or, do I have to create a separate spatial db, create a table > > > with a column of geometry type and import data into that table (from > > > places table).? If I can use the existing database, how do I enable it > > > to use PostGIS? > > > > > -- > > > You received this message because you are subscribed to the Google > Groups > > > "Django users" group. > > > To post to this group, send email to django-users@googlegroups.com. > > > To unsubscribe from this group, send email to > > > django-users+unsubscr...@googlegroups.com. > > > For more options, visit this group at > > >http://groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Confused about GeoDjango and PostGIS
Yes it can, as long PostGIS is installed. On Wed, Apr 25, 2012 at 2:37 PM, vishy wrote: > So, the existing database cannot be used as a postgis db? > > On Apr 25, 9:21 pm, Jeff Heard wrote: > > Create a new spatial database and import the data. That's by far your > > easiest option. You'll need to create a POINT column (look at the > PostGIS > > doc on how to add spatial columns) and then add rows either using the ORM > > or with a spatial query including something like this as part of the > insert: > > > > GeomFromText('POINT(' + x + ' ' + y + ')', 4326) > > > > where 4326 is the spatial reference system for longitude/latitude. > > > > > > > > > > > > > > > > On Wed, Apr 25, 2012 at 11:17 AM, vishy wrote: > > > Hi, > > > > > I need to do spatial queries like find places within 5 miles of a > > > location given in latitude and longitude. So, I am thinking of > > > exploring PostGIS and GeoDjango. I have installed both. Now, I already > > > have a database which has a table for places with latitude and > > > longitude. Can I enable this db to use postgis and add column to this > > > table? Or, do I have to create a separate spatial db, create a table > > > with a column of geometry type and import data into that table (from > > > places table).? If I can use the existing database, how do I enable it > > > to use PostGIS? > > > > > -- > > > You received this message because you are subscribed to the Google > Groups > > > "Django users" group. > > > To post to this group, send email to django-users@googlegroups.com. > > > To unsubscribe from this group, send email to > > > django-users+unsubscr...@googlegroups.com. > > > For more options, visit this group at > > >http://groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- George R. C. Silva Desenvolvimento em GIS http://geoprocessamento.net http://blog.geoprocessamento.net -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Confused about GeoDjango and PostGIS
So, the existing database cannot be used as a postgis db? On Apr 25, 9:21 pm, Jeff Heard wrote: > Create a new spatial database and import the data. That's by far your > easiest option. You'll need to create a POINT column (look at the PostGIS > doc on how to add spatial columns) and then add rows either using the ORM > or with a spatial query including something like this as part of the insert: > > GeomFromText('POINT(' + x + ' ' + y + ')', 4326) > > where 4326 is the spatial reference system for longitude/latitude. > > > > > > > > On Wed, Apr 25, 2012 at 11:17 AM, vishy wrote: > > Hi, > > > I need to do spatial queries like find places within 5 miles of a > > location given in latitude and longitude. So, I am thinking of > > exploring PostGIS and GeoDjango. I have installed both. Now, I already > > have a database which has a table for places with latitude and > > longitude. Can I enable this db to use postgis and add column to this > > table? Or, do I have to create a separate spatial db, create a table > > with a column of geometry type and import data into that table (from > > places table).? If I can use the existing database, how do I enable it > > to use PostGIS? > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-users@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group at > >http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Confused about GeoDjango and PostGIS
Create a new spatial database and import the data. That's by far your easiest option. You'll need to create a POINT column (look at the PostGIS doc on how to add spatial columns) and then add rows either using the ORM or with a spatial query including something like this as part of the insert: GeomFromText('POINT(' + x + ' ' + y + ')', 4326) where 4326 is the spatial reference system for longitude/latitude. On Wed, Apr 25, 2012 at 11:17 AM, vishy wrote: > Hi, > > I need to do spatial queries like find places within 5 miles of a > location given in latitude and longitude. So, I am thinking of > exploring PostGIS and GeoDjango. I have installed both. Now, I already > have a database which has a table for places with latitude and > longitude. Can I enable this db to use postgis and add column to this > table? Or, do I have to create a separate spatial db, create a table > with a column of geometry type and import data into that table (from > places table).? If I can use the existing database, how do I enable it > to use PostGIS? > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Confused about GeoDjango and PostGIS
Hi, I need to do spatial queries like find places within 5 miles of a location given in latitude and longitude. So, I am thinking of exploring PostGIS and GeoDjango. I have installed both. Now, I already have a database which has a table for places with latitude and longitude. Can I enable this db to use postgis and add column to this table? Or, do I have to create a separate spatial db, create a table with a column of geometry type and import data into that table (from places table).? If I can use the existing database, how do I enable it to use PostGIS? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.