Comments (4)
Hmmm... I'm not sure how NetLogo ought to handle this.
When not using the GIS extension, NaN as a value is outlawed in NetLogo. Any operation producing NaN immediately causes an error. It's a case that (as Tina has discovered) the is-number?
primitive doesn't even bother to check for, since it isn't supposed to arise in the first place.
GIS data, though, may contain NaN values that the GIS extension lets through. So how should NetLogo treat them?
It may seem rather bizarre that is-number?
is true of NaN, I mean, how much more clear could "Not a Number" be that it isn't a number? But, if it isn't a number, what is it? It may not be a number per se, there's a very strong sense in which it is nonetheless numeric. It isn't some other kind of value, and it only arises in contexts where a number is normally expected.
NetLogo isn't the only language in which the equivalent of is-number?
returns true on NaN. For example in JavaScript we have:
> typeof(NaN)
'number'
and in order to distinguish NaN from actual numbers, a separate isNaN function is provided. Java is similar; NaN is a distinct value, but not a distinct type. new java.lang.Double(1.0).getClass
and new java.lang.Double(Double.NAN).getClass
both return an identical result.
Perhaps the GIS extension shouldn't be letting the NaN values through in the first place, and should be replacing them with some valid but non-numeric NetLogo value, such as false
. That solution isn't available in statically typed languages, but in a dynamically typed language, it would work.
from gis-extension.
It's been a while, but I think the reason I went with NaN instead of some other non-numeric value was that I couldn't think of a good non-numeric value that wouldn't cause problems in at least one use case. I can think of at least two good improvements to the current situation:
- Provide a
gis:is-nan?
primitive in the GIS extension to explicitly test for NaN values, and explain in its documentation whyis-number? NaN
reports true - Allow the user to configure the representation of missing values. By default, the extension would use the current behavior so as not to break existing code. But users could also say
gis:set-nan-representation false
if they wanted to.
from gis-extension.
This issue still persists. The workaround shown in the docs using a check of ifelse (value <= 0) or (value >= 0) where value could be NaN reports an error in NetLogo6.2.2 of "can't use <= to compare between a number and not a number". The most reliable way I have found is to define a set of values you know you are looking for, and then use a member? test. This will allow one to filter null values without throwing any errors.
from gis-extension.
i think this may work
let resol 1e-4
ifelse (abs value > resol)...
from gis-extension.
Related Issues (20)
- `gis:link-dataset` and user-defined breed causes crash
- apply-raster and raster-sample generate different results HOT 1
- Exporting with gis:patch-dataset HOT 9
- Scientific e notation not recognized
- Clearer documentation about and/or support for multipart features
- nothing named gis:project-lat-lon defined error HOT 1
- Netlogo 6.2.0 breaks gis:import-wms-drawing
- NetLogo 6.2 Parsing error while loading .asc file HOT 3
- `gis:create-turtles-from-points`: Turtle placed outside of envelope when envelope set to `gis:envelope-of` the dataset in question
- netlogo 6.3 R error HOT 1
- `import-wms-drawing` fails in GIS General Examples model with Internal Server Error (HTTP code 500) HOT 1
- `gis:create-turtles-inside-polygon` fails with `Extension exception: Index 0 out of bounds for length 0` HOT 2
- NetLogo let target min-one-of neighbors math operation produced a non-number HOT 1
- gis:find-features always returns partial string matches, StringUtils.matches problem HOT 2
- GIS extension needs to support more grid data formats
- How to Enable GIS Extension to Support Gaussian Projection
- Expose coordinate transformation methods as primitives HOT 1
- Primitives to access world edges
- Add gis:set-property-value primitive
- NetLogo GIS Extension Problem HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gis-extension.