Tag Info

Hot answers tagged

32

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 ...


14

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 = ...


12

It's been a while since I used POSTGIS srids but if they are just EPSG codes then you can use http://prj2epsg.org/search to look them up from (broken) ESRI.prj files.


11

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: ...


9

Is this what you are looking for? select distinct SP_GEOMETRY.STSrid from dbo.MYTABLE This will give you a table with the different SRID's used in the table dbo.MYTABLE


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 ...


8

Well known definitions are in the gdal/data directory. You can browse the current directory source online: http://trac.osgeo.org/gdal/browser/trunk/gdal/data. Look at the gcs.csv and pcs.csv files.


8

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": [ [ ...


7

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

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

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

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.


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

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

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

You could also use Shapely's length property, i.e.: from shapely.wkt import loads l=loads('LINESTRING(3.0 4.0, 3.1 4.1)') print l.length


4

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. ...


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 ...


4

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 ...


4

The definition of SRID 4326 is in fact IN DEGREES. ALso as it says in the ST_DWithin page: Returns true if the geometries are within the specified distance of one another. For geometry units are in those of spatial reference and For geography units are in meters and measurement is defaulted to use_spheroid=true (measure around spheroid), Since you're ...


4

ST_GeomFromText('POINT(22.256 39.569)') is not going to give you a geometry in EPSG:4326. From the documentation: There are 2 variants of ST_GeomFromText function, the first takes no SRID and returns a geometry with no defined spatial reference system. The second takes a spatial reference id as the second argument and returns an ST_Geometry that ...


3

Use latitude and longitude and the great circle distance, not a map projection.


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

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

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 ...



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