I need a way to find out the unit of an EPSG-Code (e.g: meter) from java (ogr, gdal, osgeo?) but any other approach would be fine as well. I want to do something like:
if(epsg.unit==meter){
do this
} else {
do that
}
I need a way to find out the unit of an EPSG-Code (e.g: meter) from java (ogr, gdal, osgeo?) but any other approach would be fine as well. I want to do something like:
if(epsg.unit==meter){
do this
} else {
do that
}
I used the ogr java bindings:
public static void unitOfCRS(){
SpatialReference poSourceSRS = new SpatialReference();
// output: metre
poSourceSRS.ImportFromEPSG(3068);
System.out.println(poSourceSRS.GetAttrValue("UNIT"));
// output: degree
poSourceSRS.ImportFromEPSG(4326);
System.out.println(poSourceSRS.GetAttrValue("UNIT"));
}
You could perhaps look into the PROJ4 library. There seems to be a Java binding, which you could use.
I am almost confident that I have done a similar task before, although with Python, but I cannot find my code to double check.
Either way, there should be a way to get a string which includes all the parameters of a specific coordinate system. You would then use that string to extract your units.