Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Basically my question is:

Can I combine the functions of proj4 with php in my server?

For example, I would like to know if it is possible get data in WGS84 and transform in ETRS89.

I need to get WGS84 data with php, then use proj4 to transform them to ETRS89 and finally use them in php.

If the answer is right, how can I configure php and proj4 to work together???


share|improve this question
are you on a shared server, our can you install php extensions? if you can, then adding GEOS (google) and using geo-php (search github) would do It. – deroses Jun 1 '14 at 12:01
Are you sure? Geos manage spatial operations and not projections at all. – ThomasG77 Dec 17 '14 at 13:21

Yes you can get them to work together. Below is a sample of code from a php page I coded that uses proj4js, mine is slightly different going from a state plane into wgs84 but the concept is the same. (The syntax is a little off as I had problems pasting it into a code block and my code is sort of spread all over the place in a couple php files but I think you can follow the logic)

enter code here

require_once "config.php";
   foreach ($zones as $id => $zone) {
     $zone_selector .= '<option    value="'.$id.'">'.$zone['name'].'</option>';}
if ($_REQUEST['zone']) {
    $zone_id = $_REQUEST['zone'];
    $zone_name = $zones[$zone_id]['name'];
    $zone_vars = $zones[$zone_id]['vars'];}
if (!$zone_name) $zone_name = "State Plane Coordinates Converter";

points = new Array();
noaa_points = new Array();
var p;
var thispoint;

Proj4js.defs["'.$zone_id.'"] = "'.$zone_vars.'";

var dest = new Proj4js.Proj("EPSG:4326");  /* Lat and Lon projection */
var source = new Proj4js.Proj("'.$zone_id.'");

if ($_REQUEST['n'] && $_REQUEST['e']) 
{echo '
p = new Proj4js.Point('.$_REQUEST['e'].','.$_REQUEST['n'].');
points.push({num:1,north:"'.$_REQUEST['n'].'",east:"'.$_REQUEST['e'].'",zone:"'.$zone_name.'",elev:0,desc:"Single Converted Point",lat:p.y,lng:p.x,noaalat:0,noaalng:0});
share|improve this answer

If you use geoserver you can configure it to do transformations from source. Also WGS84 is practically same as ETRS89 (<1m) (You need to know when it's measured to do more accurate transformations) So you can probably play dump and just assume that they are same.

Have you considered PostGIS -> Geoserver -> PHP app stack? In that configurationyou would have PostGIS and Geoserver which both are capable to transform data.

Something like load data into PostGIS , do st_Transform , use geoserver view to server WFS or WMS layer. Or you could just use PostGIS + (SQL) from PHP, where PostGIS does all hard GIS functions and php only stores/vies data from database.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.