Hwo to load correct coordinates from a shapefile

125 views
Skip to first unread message
Assigned to seongk...@gmail.com by me

Seong

unread,
Feb 10, 2014, 2:13:38 AM2/10/14
to gama-p...@googlegroups.com
Hi, Gama users!

I am using a shapefile that has a local projection.
I loaded the shapefile using the code below, and printed coordinates of each polygon's center.

I picked a polygon and compared coordinates from Gama to coordinates from QGis.
The coordinates looks different from what I expected.

I uploaded a capture image, please see the blue rectangle (QGIS) and red rectangle (GAMA) in the image in order to compare coordinates.

Please let me know how I can get proper coordinates from the shapefile in GAMA.

Thanks for your time in advance.

from Seong

p.s: I already had a test to load the shapefile without .prj, but the results remained the same. You can get the shapefile at 


```
model test001
global {
file map_init <- file("../includes/data/test001.shp");

init {
create admin_district from: map_init with: [identifier::string(read("identifier")), area::float(read("Area")), rate_2010::float(read("rate_2010"))] 
{
write "admin_distrct:" + name + ", identifier: " + identifier + ", coordinates("+ int(((self).location).x) + ", " + int(((self).location).y) + "), area: " + area + ", rate_2010: " + rate_2010;
}
}
}

entities {
species admin_district {
string identifier <- '';
float rate_2010 <- 0.0; //<- 10.0;
float area <- 0.0; //
rgb color;//
aspect base {
draw shape color: color;
}
}

}

environment bounds: map_init;
experiment test001 type: gui {
parameter "Initial environement: " var: map_init category: "Environment";
output {
display main_display {
species admin_district aspect: base;
}
}

}

```
Screen Shot 2014-02-10 at 15.15.41.png
test001.gaml

Patrick Taillandier

unread,
Feb 10, 2014, 3:44:52 AM2/10/14
to gama-p...@googlegroups.com
Hi,

Indeed, a choice that have been made in GAMA  to translate the coordinate of geographical objects such as to put the top corner of the environment gometry (the world agent geometry) to the point {0.0, 0.0}. This choice was made in order to optimize the java2D display. But, as more and more models relied on opengl displays, we can maybe let the user decide through an option if the translation should be applied or not.

Cheers,

Patrick


--
You received this message because you are subscribed to the Google Groups "GAMA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gama-platfor...@googlegroups.com.
To post to this group, send email to gama-p...@googlegroups.com.
Visit this group at http://groups.google.com/group/gama-platform.
For more options, visit https://groups.google.com/groups/opt_out.

Seong

unread,
Feb 25, 2014, 12:47:07 AM2/25/14
to gama-p...@googlegroups.com

Hi, Patrick.

Thanks for your explanation.

As you may remember, I need to load several shapefiles and raster files to get utility values from agents' locations.
Since raster files are not considered as agents for my model, I loaded raster files (for now, csv files, which are made from ascii grid files) as matrices.

The problem is that the only clue to get values from the matrices is a predefined geographic/projected coordinate system of the raster files.
So, I had to translate Gama coordinates for the java2D display back to absolute coordinates again to overlay/match agents'locations with raster files (matrices) conceptually.

For now, I had to put some fixed codes for the reverse-translation, which only works for a fixed dataset.

If you allow the user to turn on/off the auto translation of Gama for shapefiles, it will be very convenient.

Thanks in advance.

Cheers,
Seong

Patrick Taillandier

unread,
Feb 25, 2014, 3:58:09 AM2/25/14
to gama-p...@googlegroups.com
Ok, I will add an issue on it.

Cheers,

Patrick

Srirama Bhamidipati

unread,
Feb 25, 2014, 9:37:59 AM2/25/14
to gama-p...@googlegroups.com
hi Seong,

Rather an option could be to create a custom projection in GIS software, call eg., GAMA_model_projection.prj, and define its prime meridian, latitude of origin, and may be even some false easting and northing (if you are not favorably located on the globe :D ) to get it right. You can take help of your bounding box coordinates of your shape-file to fit into GAMA frame. Then every time you want to use your gis files in GAMA, you just re-project your gis files (vector, raster both) using GAMA_model_projection.prj . This should be easier than writing a code for a specific dataset.

If you dont work in GIS a lot, you can ask somebody who works on it. Not a difficult task for them :)

regards,
Srirama
Reply all
Reply to author
Forward
0 new messages