multiple gis:find-features calls problem

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

multiple gis:find-features calls problem

backspaces
Administrator
I have a TIGER census data set for a county.  In it is an "edges" vector dataset with roads, rivers, railroad tracks and so on.

I want to pull out two of these feature sets, then create a feature set of all the rest.
So I use the following:

; first read the vector dataset
  set edge-dataset gis:load-dataset "tl_2009_35049_edges.shp"
; filter out the streets and railroad tracks
  set street-features gis:find-features edge-dataset "ROADFLG" "Y"
  set rail-features gis:find-features edge-dataset "RAILFLG" "Y"
; create a feature set of the remaining features
  set other-features gis:find-features edge-dataset "ROADFLG" "N"
  set other-features gis:find-features other-features "RAILFLG" "N"

The last find-features fails, it needs "other-features" to be a dataset, not a feature set/list.

Is there any way to fix this?
- Turn a feature set/list back into a dataset?
- Perform a more complex search with find-features?

I know I can do it by hand, but this is part of a netlogo tutorial and I want the easiest way possible!

Reply | Threaded
Open this post in threaded view
|

Re: multiple gis:find-features calls problem

Eric Russell-3
Hi Owen,

As you've discovered, the gis:find-features primitive isn't really capable
of doing anything more than the simplest query. It wouldn't be very
difficult to modify it to accept a list of features as input, but I don't
have any time to work on the GIS extension right now. And if you modify it
yourself, you'll have to distribute the modified version with your tutorial.
I would recommend doing it this way:

  set edge-dataset gis:load-dataset "tl_2009_35049_edges.shp"
  set street-features [ ]
  set rail-features [ ]
  set other-features [ ]
  foreach gis:feature-list-of edge-dataset
  [ ifelse gis:property-value ? "ROADFLG" = "Y"
    [ set street-features lput ? street-features ]
    [ ifelse gis:property-value ? "RAILFLG" = "Y"
      [ set rail-features lput ? rail-features ]
      [ set other-features lput ? other-features ] ] ]

It's not very idiomatic NetLogo, but at least it's efficient and relatively
simple.

Eric

On Sun, Jun 6, 2010 at 11:19 PM, 0wen <[hidden email]> wrote:

> I have a TIGER census data set for a county.  In it is an "edges" vector
> dataset with roads, rivers, railroad tracks and so on.
>
> I want to pull out two of these feature sets, then create a feature set of
> all the rest.
> So I use the following:
>
> ; first read the vector dataset
>  set edge-dataset gis:load-dataset "tl_2009_35049_edges.shp"
> ; filter out the streets and railroad tracks
>  set street-features gis:find-features edge-dataset "ROADFLG" "Y"
>  set rail-features gis:find-features edge-dataset "RAILFLG" "Y"
> ; create a feature set of the remaining features
>  set other-features gis:find-features edge-dataset "ROADFLG" "N"
>  set other-features gis:find-features other-features "RAILFLG" "N"
>
> The last find-features fails, it needs "other-features" to be a dataset,
> not a feature set/list.
>
> Is there any way to fix this?
> - Turn a feature set/list back into a dataset?
> - Perform a more complex search with find-features?
>
> I know I can do it by hand, but this is part of a netlogo tutorial and I
> want the easiest way possible!
>
>