GIS Extension Warning, setting NetLogo extent, and calculating patch size

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

GIS Extension Warning, setting NetLogo extent, and calculating patch size

mike_able2012
Hi! I am trying to import a shapefile that has several polygons in it and need to set the extent of the NetLogo World the same as the GIS extent for the shapefile. I then want to have each polygon represented as a separate polygon with a unique id so that I can destroy it later on if need be, while keeping the other polygons around. I have listed some sample code below. The whole construct seems to work well in the model, but the issue is that I get an error message in the Command Center several times, the same number of times as the number of shapefiles that I am importing:

"observer: GIS Extension Warning: datasets previously loaded will not be re-projected to match the new projection."

Question 1: How might I get rid of the error message?

Question 2: Is the spatial extent that I am trying to set actually being set using the code that I am implementing?

Question 3: How can I verify that my patch size is what it should be according to my GIS area calculation for the shapefile extent and number of patches being applied in NetLogo?

I would greatly appreciate help in answering these questions.

to setup-GIS ; begin "setup-GIS.nls"

 gis:load-coordinate-system ("Polygons.prj")

;;;;;; Setting NetLogo extent;;;;;;;;;; ;( taken from GIS reference map, spatial domain/extent for main shapefile with all of the polygons).

  set minx 3814 ; Left (from shapefile extent)
  set maxx 3858 ; Right (from shapefile extent)
  set miny 4187 ; Bottom (from shapefile extent)
  set maxy 4190 ; Top (from shapefile extent)
  set dataset gis:load-dataset "Polygons.shp"
;;; do this for all shapefiles;;;

;;;;;;later on;;;;;;;;;;;;
ifelse destroy? = true and destroy-now = 1 [
    gis:set-world-envelope (
         gis:envelope-union-of gis:envelope-of dataset3  
;;; (this shapefile has a slightly different spatial extent but trying to set it the same as the main shapefile, NetLogo world extent);;;
         gis:envelope-of dataset4)]  ;;; (this shapefile has a slightly different spatial extent but trying to set it the same as the main shapefile, NetLogo world extent);;;  
[
    gis:set-world-envelope (
         gis:envelope-union-of gis:envelope-of dataset2  ;;; (this shapefile has a slightly different spatial extent but trying to set it the same as the main shapefile, NetLogo world extent);;;
         gis:envelope-of dataset3
         gis:envelope-of dataset4)
  ]   ;;; loading the polygons as individual polygons with separate identification numbers. If `destroy' is set for a polygon then at initialization that polygon will not appear.


Reply | Threaded
Open this post in threaded view
|

Re: GIS Extension Warning, setting NetLogo extent, and calculating patch size

Eric Russell-3
Hi Mike,

You're getting a warning because the coordinate system is being set
after one or more datasets have already been loaded. Are you calling the
setup-GIS command more than once? Your code for setting the world
envelope looks correct. There are no primitives to directly examine the
size of patches in GIS coordinates, but once you have the world envelope
you can calculate it by dividing the envelope width by world-width, and
the envelope height by world-height.

Eric

On 10/24/12 2:45 PM, mike_able2012 wrote:

> Hi! I am trying to import a shapefile that has several polygons in it and need to set the extent of the NetLogo World the same as the GIS extent for the shapefile. I then want to have each polygon represented as a separate polygon with a unique id so that I can destroy it later on if need be, while keeping the other polygons around. I have listed some sample code below. The whole construct seems to work well in the model, but the issue is that I get an error message in the Command Center several times, the same number of times as the number of shapefiles that I am importing:
>
> "observer: GIS Extension Warning: datasets previously loaded will not be re-projected to match the new projection."
>
> Question 1: How might I get rid of the error message?
>
> Question 2: Is the spatial extent that I am trying to set actually being set using the code that I am implementing?
>
> Question 3: How can I verify that my patch size is what it should be according to my GIS area calculation for the shapefile extent and number of patches being applied in NetLogo?
>
> I would greatly appreciate help in answering these questions.
>
> to setup-GIS ; begin "setup-GIS.nls"
>
>   gis:load-coordinate-system ("Polygons.prj")
>
> ;;;;;; Setting NetLogo extent;;;;;;;;;; ;( taken from GIS reference map, spatial domain/extent for main shapefile with all of the polygons).
>
>    set minx 3814 ; Left (from shapefile extent)
>    set maxx 3858 ; Right (from shapefile extent)
>    set miny 4187 ; Bottom (from shapefile extent)
>    set maxy 4190 ; Top (from shapefile extent)
>    set dataset gis:load-dataset "Polygons.shp"
> ;;; do this for all shapefiles;;;
>
> ;;;;;;later on;;;;;;;;;;;;
> ifelse destroy? = true and destroy-now = 1 [
>      gis:set-world-envelope (
>           gis:envelope-union-of gis:envelope-of dataset3
> ;;; (this shapefile has a slightly different spatial extent but trying to set it the same as the main shapefile, NetLogo world extent);;;
>           gis:envelope-of dataset4)]  ;;; (this shapefile has a slightly different spatial extent but trying to set it the same as the main shapefile, NetLogo world extent);;;
> [
>      gis:set-world-envelope (
>           gis:envelope-union-of gis:envelope-of dataset2  ;;; (this shapefile has a slightly different spatial extent but trying to set it the same as the main shapefile, NetLogo world extent);;;
>           gis:envelope-of dataset3
>           gis:envelope-of dataset4)
>    ]   ;;; loading the polygons as individual polygons with separate identification numbers. If `destroy' is set for a polygon then at initialization that polygon will not appear.
>

Reply | Threaded
Open this post in threaded view
|

Re: GIS Extension Warning, setting NetLogo extent, and calculating patch size

mike_able2012
Thanks Eric! I was calling that command more than once. I made the suggested change and now the warning is gone.

Mike.

--- In [hidden email], Eric Russell <erussell100@...> wrote:

>
> Hi Mike,
>
> You're getting a warning because the coordinate system is being set
> after one or more datasets have already been loaded. Are you calling the
> setup-GIS command more than once? Your code for setting the world
> envelope looks correct. There are no primitives to directly examine the
> size of patches in GIS coordinates, but once you have the world envelope
> you can calculate it by dividing the envelope width by world-width, and
> the envelope height by world-height.
>
> Eric
>
> On 10/24/12 2:45 PM, mike_able2012 wrote:
> > Hi! I am trying to import a shapefile that has several polygons in it and need to set the extent of the NetLogo World the same as the GIS extent for the shapefile. I then want to have each polygon represented as a separate polygon with a unique id so that I can destroy it later on if need be, while keeping the other polygons around. I have listed some sample code below. The whole construct seems to work well in the model, but the issue is that I get an error message in the Command Center several times, the same number of times as the number of shapefiles that I am importing:
> >
> > "observer: GIS Extension Warning: datasets previously loaded will not be re-projected to match the new projection."
> >
> > Question 1: How might I get rid of the error message?
> >
> > Question 2: Is the spatial extent that I am trying to set actually being set using the code that I am implementing?
> >
> > Question 3: How can I verify that my patch size is what it should be according to my GIS area calculation for the shapefile extent and number of patches being applied in NetLogo?
> >
> > I would greatly appreciate help in answering these questions.
> >
> > to setup-GIS ; begin "setup-GIS.nls"
> >
> >   gis:load-coordinate-system ("Polygons.prj")
> >
> > ;;;;;; Setting NetLogo extent;;;;;;;;;; ;( taken from GIS reference map, spatial domain/extent for main shapefile with all of the polygons).
> >
> >    set minx 3814 ; Left (from shapefile extent)
> >    set maxx 3858 ; Right (from shapefile extent)
> >    set miny 4187 ; Bottom (from shapefile extent)
> >    set maxy 4190 ; Top (from shapefile extent)
> >    set dataset gis:load-dataset "Polygons.shp"
> > ;;; do this for all shapefiles;;;
> >
> > ;;;;;;later on;;;;;;;;;;;;
> > ifelse destroy? = true and destroy-now = 1 [
> >      gis:set-world-envelope (
> >           gis:envelope-union-of gis:envelope-of dataset3
> > ;;; (this shapefile has a slightly different spatial extent but trying to set it the same as the main shapefile, NetLogo world extent);;;
> >           gis:envelope-of dataset4)]  ;;; (this shapefile has a slightly different spatial extent but trying to set it the same as the main shapefile, NetLogo world extent);;;
> > [
> >      gis:set-world-envelope (
> >           gis:envelope-union-of gis:envelope-of dataset2  ;;; (this shapefile has a slightly different spatial extent but trying to set it the same as the main shapefile, NetLogo world extent);;;
> >           gis:envelope-of dataset3
> >           gis:envelope-of dataset4)
> >    ]   ;;; loading the polygons as individual polygons with separate identification numbers. If `destroy' is set for a polygon then at initialization that polygon will not appear.
> >
>


Reply | Threaded
Open this post in threaded view
|

Re: GIS Extension Warning, setting NetLogo extent, and calculating patch size

indah_mahendra
In reply to this post by Eric Russell-3
extensions [ gis ]
 globals [ dkimap-dataset ]
 to setup
   clear-all
   gis:load-coordinate-system ("dkimap.prj")
   set dkimap-dataset gis:load-dataset "dkimap.shp"
   gis:set-world-envelope gis:envelope-of dkimap-dataset
 reset-ticks
 end
 

 observer: GIS Extension Warning: datasets previously loaded will not be re-projected to match the new projection.

 

 I got the same error message, can you help me on this? did I miss something? thank you