Tag Info

Hot answers tagged

27

GDAL has a nice convenient interface to the PROJ4 library. If you are confident with Python, using the GDAL Python bindings, if you import the osr classes you will have very convenient methods for reading and exporting projection representations to a variety of formats like PROJ4, WKT, Esri .PRJ. For example this script will convert your .PRJ file of your ...


12

The geopy module provides the Vincenty formula, which provides accurate ellipsoid distances. Couple this with the wkt loading in Shapely, and you have reasonably simple code: from geopy import distance from shapely.wkt import loads line_wkt="LINESTRING(3.0 4.0, 3.1 4.1)" # a number of other elipsoids are supported distance.VincentyDistance.ELLIPSOID = ...


8

The first step to determining the correct projection of any layer, is to find the projection information, if any, that came with your layer. In the case of a Shapefile, like what you downloaded from Census.gov, that information is contained in a .prj file, short for Projection. Here are the contents of the projection file from the census data: ...


8

Borrowing the idea from @iant, here is a PL/Python3 module that will look up the EPSG SRID integer codes from a PRJ file using the http://prj2epsg.org web service. First, install PL/Python3: CREATE LANGUAGE plpython3u; an now add the SQL function, which has code written for Python 3: CREATE OR REPLACE FUNCTION prj2epsg(prj_file text) RETURNS integer AS ...


6

I would note that if you have curl support in your GDAL build (a very common configuration), you can simply give the spatialreference.org URL for the SRS and it will fetch what it needs and dereference it appropriately. -a_srs http://spatialreference.org/ref/epsg/4326/ -t_srs http://spatialreference.org/ref/epsg/26915


6

Following on from the answer given by @atlefren, an SRID usually is made of two components, an "authority" and an identifier. The authority is just the name of the organization that catalogues the identifiers. The most common authority you'll see is EPSG, which sands for the "European Petroleum Survey Group", and they have a comprehensive database of ...


6

Wikipedia: A Spatial Reference System Identifier (SRID) is a unique value used to unambiguously identify projected, unprojected, and local spatial coordinate system definitions. In other words, a system of indentifiers for spatial reference system, so that i can tell a GIS application (like postGIS) that my data is in WGS84 Geographic coordinates by ...


6

Taking a look at the source code of PostGIS I found out how it parses SRIDs. Here is the correct way to specify the SRID in GeoJSON. The GeoJSON specification says that the coordinates of a polygon are an array of line strings. Therefore I had to wrap them with additional brackets. { "type":"Polygon", "coordinates": [ [ ...


5

To get the coordinate system of your table use the following: SELECT ST_SRID(the_geom) FROM your_table_name LIMIT 1; For your second question, I am not sure if EPSG:4283 is by default defined in spatial_ref_sys table. In case it is not, you can use a INSERT command. This definition is from spatialreference.org: INSERT into spatial_ref_sys (srid, ...


5

You have loaded your data with the wrong SRID. 4269 is lon/lat NAD 83. 4326 is lon/lat WGS 84. They are practically the same projection, and both geographic. Judging from your coordinates, the data is actually in some planar projection, though without knowing extra information (like where you are) I can't even take an informed guess as to which one.


5

Because spatialreference.org pre-dates PostGIS 2.0, when the SRID key limitation was added No problems with your workaround sr.org is basically defunct, there's no active maintainers, you can file a ticket for posterity and the next maintainers at http://trac.osgeo.org/metacrs/ under the sr.org category. The '9' was probably tacked on to avoid conflicting ...


5

Sounds like the point just isn't in the polygon. WITH pt AS ( SELECT ST_SetSRID(ST_MakePoint(-159.717,21.933), 4326) AS geom ) SELECT ST_Distance(states.geom, pt.geom) FROM states, pt WHERE states.abbr = 'HI'; And Google seems to think so too. It's close, but it's not in. https://maps.google.ca/maps?client=safari&oe=UTF-8&q=21.933N+159.717W


5

When talking about geographic locations, we usually say and use Lat-long. This has been codified in the ISO 6709 standard. When dealing with Cartesian coordinate geometry, we generally use X-Y. Many GIS systems, work with a Geographic Location as a special case of a 2 D coordinate point, where the X represents the longitude and Y represents the Latitude. ...


4

There is no native way to do this in SQL Server (isn't ST_Transform a PostGIS method?). Look into something like SQL Server Spatial Tools and this post from a few weeks back. Also, you won't find any projected coordinate systems in the sys.spatial_reference_systems table as that table is only GEOGCS and used for geography datatypes.


4

As a mix of solutions I have created a script to help me load arbitrary shapefiles into postgis. It also tries to detect the encoding of the DBF. from chardet.universaldetector import UniversalDetector import os.path import sys import dbfUtils import sys from osgeo import osr from urllib import urlencode from urllib2 import urlopen import json shp_file = ...


4

Postgis, spatialite and Qgis mainly use GDAL/Proj definitions with EPSG codes as ID for CRS. You find a lot of them at spatialreference.org, but that database is a bit outdated. For Dutch RD, there is EPSG:28991 Amersfoort/RD Old EPSG:28992 Amersfoort/RD New Oracle used their own SRID up to release 10.1, and switched to EPSG codes as of release 10.2 ...


3

You cannot do that. Geometry and Geography are two completely different types of data. You probably did read up on it..., but here is an explanation... Geometry are points on a flat surface. If you would like to calculate the area of your bedroom, i.e. 3.5m by 6.8m, it would result in 23.8m2 - if you would have drawn it in a CAD program, you would start ...


3

At a guess, your point should be about 5.5km southeast of Bad Reichenhall right? If so, the problem you have is you're interpreting your input coordinates incorrectly. The clue is in the source projection's name: LAEA which stands for Lambert Azimuthal Equal-Area, which is a projection that uses linear units (metres in this case) rather than angular units. ...


3

You need to populate your spatial_ref_sys table, e.g.: psql -d your_db -f spatial_ref_sys.sql This will give you SRID 4326, but not 94283, which doesn't appear to be any publicly recognized SRID. To add 900913 (i.e. leetspeek for GOOGLE), see the PostGIS instructions at http://trac.osgeo.org/openlayers/wiki/SphericalMercator


3

srsly. I want one too. Many people seem to look them up at http://spatialreference.org When you import shapefiles using PostGIS (and the PostGIS loader for PGAdmin), it looks up the proj information in a table called spatial_ref_sys. From what I understand, the standard spatial_ref_sys table packaged with PostGIS includes only OGC WKT (Open Geospatial ...


3

Check geometry_columns table: Does it contain a line for "world" table with SRID = 4326? If not, add/edit it. (The shapefile from thematicmapping.org seems to be in 4326.) Also, looks like the conversion from geometry to geography is missing: "the_geom"::geography


3

From Postgis doc: The syntax is find_srid(, , ) and the function returns the integer SRID of the specified column by searching through the GEOMETRY_COLUMNS table. If the geometry column has not been properly added with the AddGeometryColumns() function, this function will not work either. So you shoud have a row in GEOMETRY_COLUMNS table for ...


3

You need to use UpdateGeometrySRID. If you are just correcting a mistake, that's fine. If not you also need to use ST_Transform (the documentation explains this). Also see this post.


3

Are you sure those are the correct coordinates? On Google Maps, the best way to grab the coordinates is to click on the small "Maps Labs" link and enable "LatLng Marker". Then right-click on both locations, and click "drop LatLng marker". This will show: -73.9740, 40.7638 and -73.9845, 40.7490 (I've rearranged to be in longitude, latitude order to ...


3

I guess you are confused with what the different coordinates are. EPSG:900913 (officially EPSG:3857) has an extent (worldwide) of -20037508.34,-20037508.34,20037508.34,20037508.34 Your point (-8.397 43.3708) does not seem to be in this range (it's in portugal, right?) This means that your point is in EPSG:4326 ("lat/lons") already. You ...


3

At the very bottom of that link to common SRIDs is a line with a link to the EPSG registry where you can search for more SRIDs. Putting in Louisiana South comes up with a few options, the one SaultDon mentioned (EPSG:3452) being the closest match (ie, NAD83, no HARN, and using feet). However, the word 'truncated' gives me pause. A quick search led to this ...


2

I'd use ogr2ogr (http://www.gdal.org/ogr/index.html) to do it directly but if you really must use python then there are python bindings (http://pypi.python.org/pypi/GDAL/) to let you do it.


2

The ST_Transform function takes the output coordinate system as the second parameter - see ST_Transform. The input co-ordinates should already be stored in the GEOMETRY_COLUMNS table / view. Also, you seem to have the SRID wrong, it is 4326 for standard WGS84 lat/lon.


2

Are you sure you have GEOS and the proj4 libraries installed and configured properly to work with GeoDjango? If not, it will not be able to do the right geometry check (without GEOS, you only get bbox calculations) or coordinate system transformations (handled by proj4 - which needs to have the SRID database accessible). Your other option is to do the ...


2

I inserted a point in PostGIS, with SRID 300 and then inserted the same point with SRID 350, I found the two points showing the same place, in QGIS viewer. There is no SRID 300 or 350. QGIS just defaulted to the same CRS for both points. That's why they showed up in the same place. QGIS comes with a CRS database which it uses to determine how to ...



Only top voted, non community-wiki answers of a minimum length are eligible