English 中文(简体)
How to convert latitude/longitude in degrees to BBOX where SRS=EPSG:27700
原标题:

Anyone know how to convert latitude, longitude in degrees to define a BBOX where SRS=EPSG:27700?

I am trying to call a WMS service with a URL like following (not a real link): http://mysecretmappingserver.com/wms?user=myuser&pwd=mypassword&VERSION=1.1.1&REQUEST=GetMap&LAYERS=ap25cm&STYLES=&SRS=EPSG:27700&BBOX=229096,231675,229296,231875&width=400&height=400

Any language would be fine; C# preferable.

Spacedman has been trying to help me, but I can t seem to get Proj4Net to work for me - all me, I m sure - but if someone knows either Proj4Net or the math involved, that might be better...

最佳回答

You need an interface to the PROJ.4 projections library in your language of choice. In R, for example, its in the rgdal package:

Here s some points (1,1 to 2,2 degrees) in epsg:4326:

> pts
SpatialPoints:
     coords.x1 coords.x2
[1,]         1         1
[2,]         2         2
Coordinate Reference System (CRS) arguments: +init=epsg:4326 

and voila:

> spTransform(pts,CRS("+init=epsg:27700"))
SpatialPoints:
     coords.x1 coords.x2
[1,]  734005.9  -5416918
[2,]  845270.7  -5305999
Coordinate Reference System (CRS) arguments: +init=epsg:27700

Proj.4 docs here:

http://trac.osgeo.org/proj/

Since this is OSGB, probably a better example would be in the UK: here s a point in central london:

> pts = SpatialPoints(cbind(-0.109863,51.460852),proj4string=CRS("+init=epsg:4326"))
> spTransform(pts,CRS("+init=epsg:27700"))SpatialPoints:
     coords.x1 coords.x2
[1,]  531407.1  175235.8
Coordinate Reference System (CRS) arguments: +init=epsg:27700
+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000
+y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs
+towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894 
问题回答

I recommend ogr2ogr, which among other things can convert between projections. I have it installed on my Mac, and there are binding e.g. to Python and many other languages. You can also use it on the commandline. Homepage is http://www.gdal.org/ogr2ogr.html





相关问题
how to create image from gis data in C#

I m using C# to pull spatial data from a sql server 2008 database. I m then trying to perform operations on that data, but to start... I want to be able to visualize it. That is, I would like to ...

Geospatial library for the iPhone

I m thinking about creating a location-aware iPhone app that could work offline by coming packaged with a list of points of interest (POIs). The app would read the user s current location from ...

热门标签