Compressing TIFF files in R and Windows

Compressing TIFF files is an easy way to save disk space when working with raster files or image outputs for research papers. But this is rarely the default option causing used diskspace to quickly inflate heavily. For instance this figure 7000 by 5000 pixel image as a TIFF uses 136MB.



While after lossless compression with the libtiff command tiffcp it is only 8MB. To install libtiff on windows download and run the latest setup from http://gnuwin32.sourceforge.net/packages/tiff.htm. To compress a tiff file you need to run the following command (assuming that tiffcp is in your path). Make sure to specify a different output file name, otherwise the original will be overwritten with a broken and incomplete copy of the original.
tiffcp -c lzw uncompressed_input.tif compressed_output.tif

In R you can also write compressed raster (geo)tiff files by adding extra options to the writeRaster function from the raster package.

library(raster)

x <- raster("uncompressed_input.tif")
tifoptions <- c("COMPRESS=DEFLATE", "PREDICTOR=2", "ZLEVEL=6")
writeRaster(x, "compressed_output.tif",
            options = tifoptions, overwrite = FALSE)

Geographic null models for species distribution modeling: An implementation combining BIOMOD2 and dismo [Code Dump]

Warning this is more of a code dump instead of a blogpost but I'm still putting it out there hoping it's still useful for someone else as it has been sitting in my draft folder for far too long. Anyways the paper by Robert Hijmans is really worth reading if you're interested in the evaluation of species distribution models. If you have questions, don't hesitate to contact me.

Geographic null model from paper by Robert Hijsmans (link to paper).
package dismo (maintained by Robert J. Hijmans). and the package BIOMOD2.

Load libraries:

library("biomod2")
library("dismo")

The null_model_evaluation function takes as input a BIOMOD2 model.

null_model_evaluation <- function(models) {
  ## flow
  ## 1) create geographic null model from the points used as training data
  ## 2) compare AUC of the model with AUC of the geographic null model (use same presence/absence data)
  
  ## extract test data from models
  data <- get_formal_data(models)
  calib.lines <- get(load(models@calib.lines@link))
  nbOfRuns <- (length(calib.lines) / length(data@data.species))
  calib.lines.mat <- as.matrix(calib.lines, nrow=length(data@data.species), ncol=nbOfRuns)

  evaluations <- get_evaluations(models)
  dims <- dimnames(evaluations)
  rocIndex <- which(dims[1][[1]] == "ROC")
  testingDataIndex <- which( dims[2][[1]] == "Testing.data")
  
  species.data <- data@coord[which(data@data.species == 1),]
  background.data <- data@coord[is.na(data@data.species),]
  
  result <- array(dim=c(nbOfRuns, 2, length(dims[3][[1]])), dimnames=list(dims[4][[1]],c("model", "geo_null_model"), dims[3][[1]]))
  
  ## calculate geographic null models
  for( methodIndex in 1:length(dims[3][[1]])){
    for (runIndex in 1:nbOfRuns){
      model.auc <- evaluations[rocIndex, testingDataIndex,methodIndex,runIndex,1]
      result[runIndex,1,methodIndex] <- model.auc
      
      train.species.data <- species.data[calib.lines[1:nrow(species.data),runIndex],]
      test.species.data <- species.data[!calib.lines[1:nrow(species.data),runIndex],]
      if (nrow(test.species.data) > 0 & !is.na(model.auc)){
        train.background.data <- background.data[calib.lines[nrow(species.data)+1:nrow(calib.lines)-nrow(species.data),runIndex],]
        test.background.data <- background.data[!calib.lines[nrow(species.data)+1:nrow(calib.lines)-nrow(species.data),runIndex],]
        gd <- geoDist(train.species.data, lonlat=TRUE)
        #p <- predict(gd, env)
        #plot(p)
        #points(train.background.data, pch=16, col="purple")
        #points(test.background.data, pch=16, col="blue")
        #points(train.species.data, pch=16, col="green")
        #points(test.species.data, pch=16, col="red")
        gd.evaluation <- evaluate(gd, p=test.species.data, a=test.background.data)
        result[runIndex,2,methodIndex] <- gd.evaluation@auc
      }
    }
  }
  result
}



Workaround for: SQL Expression Parsing Error: memory exhausted in QGIS or OGR

Today I encountered an issue when I was trying to build a query with a lot of ids in an "IN" clause. I was trying to only show the polygons near Europe from the Global Self-consistent Hierarchical High-resolution Geography dataset (GSHHG) but thus wanted to only show more than 5500 id's.

With some find and replace actions I managed to built the following query:
"id" IN ('0-E','1','6','14','23','25','38','49','51','61','81','85','90','93','114','138','143','144','148','158','159','168','176','182','185','195','212','220','222','223','227','233','235','246','248','255','261','262','293','295','301','323','328','330','338','341','347','352','361','365','366','371','372','375','382','387','400','404','406','413','421','424','426','428','433','434','436','444','455','471','474','478','485','486','513','529','532','534','538','548','557','560','562','565','571','584','587','589','593','602','604','609','619','631','649','653','668','672','673','681','685','686','694','703','704','706','707','711','716','731','734','741','752','757','765','777','782','786','791','796','799','805','807','814','821','823','831','836','839','849','867','871','884','888','890','892','894','896','914','915','928','935','936','955','961','966','971','972','976','977','1000','1014','1035','1038','1046','1047','1049','1097','1100','1101','1105','1110','1115','1117','1120','1121','1122','1130','1133','1160','1174','1177','1187','1195','1209','1223','1229','1232','1243','1260','1261','1262','1268','1279','1291','1299','1306','1307','1310','1312','1315','1318','1323','1326','1332','1340','1351','1354','1372','1381','1392','1393','1396','1413','1418','1428','1432','1438','1445','1446','1449','1453','1461','1466','1482','1489','1501','1502','1505','1513','1520','1528','1532','1537','1539','1545','1547','1556','1560','1561','1564','1567','1570','1578','1584','1587','1592','1594','1595','1597','1603','1614','1622','1643','1655','1659','1660','1667','1680','1685','1687','1688','1696','1697','1701','1737','1756','1757','1767','1777','1789','1790','1797','1814','1815','1826','1827','1836','1840','1842','1843','1844','1846','1853','1863','1864','1867','1878','1881','1883','1889','1894','1899','1903','1926','1927','1928','1936','1948','1957','1964','1980','2003','2005','2018','2025','2026','2033','2043','2044','2055','2057','2062','2072','2073','2074','2079','2088','2089','2092','2095','2101','2107','2119','2131','2153','2156','2157','2162','2171','2176','2187','2190','2196','2198','2209','2242','2256','2265','2285','2287','2288','2290','2299','2318','2319','2324','2340','2342','2363','2365','2373','2374','2377','2383','2387','2395','2402','2413','2414','2421','2433','2441','2453','2467','2478','2481','2483','2487','2499','2503','2514','2533','2544','2546','2550','2556','2565','2567','2573','2574','2577','2582','2588','2589','2598','2603','2610','2614','2615','2620','2632','2640','2663','2664','2684','2714','2722','2725','2726','2748','2750','2758','2761','2764','2775','2778','2786','2788','2790','2806','2814','2815','2817','2820','2829','2834','2837','2856','2875','2881','2898','2902','2908','2932','2948','2949','2955','2959','2969','2973','2979','3000','3001','3003','3009','3015','3018','3019','3038','3055','3057','3071','3081','3082','3092','3093','3094','3117','3119','3127','3132','3133','3140','3160','3165','3184','3188','3195','3200','3205','3215','3216','3226','3229','3230','3236','3255','3256','3259','3260','3287','3288','3297','3323','3325','3329','3331','3340','3345','3358','3365','3372','3376','3384','3388','3404','3405','3421','3423','3430','3450','3460','3468','3476','3477','3483','3487','3497','3499','3500','3508','3514','3515','3516','3527','3532','3533','3555','3576','3585','3602','3603','3631','3641','3643','3646','3648','3649','3651','3652','3658','3671','3673','3681','3687','3688','3693','3702','3713','3716','3719','3723','3762','3765','3769','3777','3786','3793','3802','3803','3807','3808','3814','3816','3821','3826','3829','3831','3837','3839','3841','3842','3845','3852','3855','3856','3860','3865','3869','3872','3877','3888','3889','3899','3903','3905','3916','3918','3926','3929','3941','3947','3950','3953','3962','3970','3982','4015','4018','4030','4031','4040','4041','4044','4050','4055','4069','4071','4072','4076','4084','4085','4087','4093','4095','4106','4109','4113','4118','4119','4121','4124','4125','4129','4153','4156','4165','4174','4180','4192','4208','4214','4220','4225','4228','4231','4240','4268','4277','4281','4294','4295','4297','4303','4318','4324','4325','4326','4327','4337','4343','4345','4351','4354','4359','4364','4365','4388','4392','4398','4404','4405','4424','4431','4445','4458','4466','4468','4470','4472','4480','4487','4492','4493','4498','4499','4504','4510','4513','4521','4531','4543','4546','4549','4552','4556','4557','4558','4561','4562','4576','4583','4586','4597','4614','4617','4627','4646','4649','4654','4664','4668','4714','4723','4728','4752','4760','4761','4763','4767','4772','4791','4814','4823','4825','4840','4841','4847','4850','4865','4873','4884','4893','4895','4905','4918','4920','4935','4936','4943','4953','4964','4969','4978','4979','4980','4994','5003','5015','5017','5019','5021','5028','5030','5033','5039','5041','5042','5046','5050','5052','5053','5062','5064','5072','5079','5083','5087','5098','5111','5113','5119','5121','5147','5148','5154','5157','5159','5178','5185','5186','5192','5193','5201','5223','5238','5240','5251','5253','5260','5280','5288','5296','5297','5305','5306','5310','5313','5316','5319','5327','5329','5346','5347','5348','5362','5370','5371','5372','5382','5400','5411','5416','5427','5433','5438','5440','5444','5447','5453','5458','5459','5461','5465','5472','5474','5475','5483','5487','5494','5504','5507','5527','5536','5539','5542','5548','5561','5563','5564','5569','5571','5581','5584','5587','5588','5604','5609','5610','5614','5635','5642','5652','5653','5662','5669','5673','5678','5683','5691','5693','5695','5699','5704','5730','5732','5735','5743','5748','5758','5765','5766','5768','5770','5774','5779','5792','5811','5814','5819','5829','5830','5831','5856','5862','5875','5876','5879','5883','5885','5899','5903','5907','5908','5913','5921','5934','5941','5948','5953','5960','5964','5969','5973','5981','5985','5992','5993','5996','5998','6002','6004','6008','6015','6018','6020','6028','6034','6036','6048','6049','6059','6067','6073','6081','6084','6086','6093','6114','6122','6130','6137','6138','6142','6143','6157','6163','6165','6167','6178','6187','6192','6195','6201','6205','6206','6209','6218','6230','6245','6254','6260','6264','6275','6280','6281','6284','6305','6308','6312','6325','6326','6334','6359','6360','6362','6367','6373','6379','6389','6390','6394','6403','6417','6420','6423','6438','6443','6451','6459','6463','6466','6468','6470','6477','6482','6491','6500','6505','6509','6514','6518','6520','6525','6528','6541','6544','6547','6551','6559','6574','6585','6589','6594','6606','6609','6619','6627','6661','6668','6670','6671','6674','6680','6688','6696','6699','6707','6713','6718','6724','6745','6751','6755','6773','6781','6798','6810','6812','6844','6859','6860','6877','6878','6879','6888','6889','6891','6893','6901','6909','6912','6925','6926','6932','6935','6942','6943','6950','6957','6970','6976','6981','6987','6989','6990','6991','6997','7001','7005','7026','7027','7035','7048','7053','7057','7059','7061','7064','7080','7083','7089','7090','7091','7092','7094','7096','7104','7106','7108','7111','7112','7115','7129','7137','7144','7155','7157','7167','7177','7180','7200','7202','7214','7232','7235','7238','7248','7252','7256','7268','7272','7287','7292','7301','7322','7324','7326','7331','7333','7346','7349','7356','7359','7361','7371','7376','7377','7387','7388','7394','7401','7426','7427','7432','7435','7437','7438','7445','7446','7451','7454','7468','7485','7486','7514','7517','7536','7540','7544','7551','7555','7557','7572','7577','7589','7604','7606','7626','7627','7633','7642','7643','7652','7654','7668','7690','7696','7697','7702','7717','7721','7743','7746','7748','7749','7750','7751','7760','7764','7765','7772','7777','7779','7808','7813','7828','7863','7870','7876','7884','7889','7897','7898','7900','7903','7911','7912','7919','7922','7925','7934','7936','7944','7945','7947','7962','7964','7969','7975','7978','7990','7994','8000','8015','8023','8028','8035','8040','8041','8048','8051','8055','8056','8057','8062','8071','8080','8083','8086','8097','8102','8106','8113','8120','8135','8139','8152','8164','8172','8174','8175','8178','8182','8191','8199','8205','8210','8211','8216','8221','8223','8224','8232','8240','8241','8252','8275','8292','8303','8306','8307','8321','8326','8335','8350','8358','8365','8374','8376','8386','8387','8396','8398','8404','8411','8433','8443','8456','8458','8479','8482','8489','8496','8499','8504','8511','8521','8523','8524','8529','8530','8534','8538','8548','8549','8555','8558','8561','8562','8571','8579','8589','8593','8606','8614','8628','8629','8638','8640','8653','8661','8669','8676','8694','8698','8720','8723','8729','8733','8742','8745','8752','8756','8758','8763','8774','8791','8795','8809','8816','8820','8821','8836','8837','8838','8840','8845','8849','8851','8853','8856','8865','8867','8877','8878','8892','8901','8906','8912','8914','8915','8923','8941','8946','8956','8972','8981','8986','8991','8992','9007','9023','9026','9039','9041','9049','9074','9077','9086','9096','9101','9106','9114','9120','9132','9135','9137','9138','9159','9161','9164','9183','9189','9204','9210','9217','9220','9226','9228','9231','9236','9237','9239','9243','9245','9248','9250','9260','9262','9264','9274','9277','9299','9310','9311','9314','9316','9336','9356','9365','9367','9368','9370','9374','9378','9393','9398','9411','9415','9439','9440','9452','9468','9470','9474','9476','9477','9484','9493','9507','9516','9517','9534','9538','9542','9554','9557','9569','9570','9579','9587','9602','9613','9626','9636','9672','9691','9713','9725','9739','9744','9747','9754','9758','9760','9763','9765','9772','9775','9778','9779','9792','9801','9818','9826','9864','9871','9875','9876','9920','9921','9923','9929','9939','9943','9949','9953','9957','9971','9984','9991','10007','10010','10017','10020','10026','10027','10034','10046','10053','10055','10058','10060','10061','10063','10067','10077','10078','10095','10101','10106','10132','10133','10135','10140','10149','10150','10157','10160','10163','10181','10190','10192','10208','10221','10226','10243','10251','10256','10271','10274','10279','10289','10296','10305','10314','10348','10368','10372','10373','10379','10388','10403','10417','10428','10429','10432','10433','10435','10436','10442','10444','10449','10452','10453','10456','10460','10472','10495','10504','10513','10540','10546','10551','10561','10580','10586','10587','10589','10599','10612','10632','10642','10644','10645','10647','10660','10679','10681','10682','10684','10685','10687','10692','10693','10697','10709','10715','10720','10738','10745','10748','10751','10760','10762','10773','10788','10797','10798','10800','10819','10820','10826','10830','10859','10860','10863','10867','10877','10884','10895','10896','10902','10909','10910','10911','10912','10914','10916','10918','10921','10924','10937','10941','10968','10980','10981','10984','10987','10988','10993','10997','11003','11023','11026','11051','11056','11066','11077','11082','11086','11091','11092','11102','11108','11110','11118','11128','11138','11141','11146','11174','11177','11180','11194','11195','11205','11208','11213','11217','11220','11224','11243','11244','11253','11255','11262','11270','11272','11285','11287','11296','11297','11301','11307','11308','11318','11321','11339','11346','11356','11364','11366','11370','11375','11377','11380','11404','11405','11410','11414','11417','11446','11448','11451','11459','11464','11476','11479','11502','11512','11515','11537','11541','11542','11544','11551','11563','11565','11578','11581','11585','11592','11595','11599','11600','11605','11618','11630','11637','11643','11648','11652','11654','11657','11664','11667','11671','11674','11677','11678','11688','11698','11699','11701','11705','11707','11710','11721','11724','11728','11736','11751','11757','11758','11762','11771','11780','11783','11784','11796','11798','11801','11809','11813','11821','11826','11844','11845','11848','11854','11858','11863','11864','11867','11871','11874','11891','11892','11894','11897','11902','11907','11910','11912','11914','11917','11943','11947','11950','11958','11967','11999','12023','12028','12036','12039','12060','12066','12074','12076','12080','12082','12086','12087','12096','12106','12115','12120','12126','12136','12139','12143','12150','12155','12159','12164','12182','12193','12195','12196','12205','12213','12238','12242','12244','12253','12257','12271','12281','12284','12292','12295','12301','12318','12329','12337','12338','12352','12360','12363','12364','12374','12382','12401','12432','12438','12440','12443','12444','12455','12459','12461','12464','12486','12491','12498','12510','12513','12514','12534','12537','12539','12540','12551','12564','12567','12573','12574','12581','12584','12586','12600','12603','12611','12615','12625','12629','12638','12642','12656','12659','12661','12671','12677','12678','12684','12692','12693','12695','12697','12716','12724','12735','12756','12775','12787','12790','12805','12809','12824','12835','12837','12844','12845','12857','12861','12868','12876','12880','12881','12884','12893','12903','12908','12923','12926','12935','12940','12947','12953','12956','12965','12977','12979','12980','12984','12992','12996','12998','13002','13012','13027','13062','13066','13081','13087','13100','13103','13106','13107','13117','13120','13123','13131','13146','13148','13149','13154','13160','13162','13166','13170','13184','13185','13186','13190','13192','13193','13196','13215','13216','13218','13219','13230','13238','13239','13244','13247','13253','13259','13265','13266','13269','13282','13285','13286','13289','13300','13301','13307','13312','13313','13318','13320','13331','13332','13357','13358','13366','13367','13375','13389','13407','13408','13409','13410','13416','13429','13433','13438','13440','13459','13465','13470','13475','13481','13482','13483','13486','13487','13490','13502','13505','13506','13510','13514','13527','13540','13545','13546','13547','13564','13565','13566','13570','13572','13576','13578','13580','13581','13583','13585','13591','13593','13595','13597','13601','13606','13611','13619','13624','13631','13635','13637','13638','13639','13651','13660','13678','13683','13686','13726','13729','13732','13737','13738','13741','13742','13756','13759','13762','13765','13769','13770','13775','13784','13792','13805','13808','13820','13827','13834','13841','13855','13857','13862','13868','13871','13881','13882','13889','13891','13896','13905','13911','13913','13926','13929','13932','13942','13962','13989','13990','13994','13995','13997','14003','14004','14006','14007','14010','14013','14015','14017','14019','14024','14026','14030','14033','14034','14069','14075','14078','14080','14081','14082','14085','14089','14090','14091','14093','14097','14099','14106','14107','14113','14116','14135','14147','14149','14153','14158','14160','14168','14169','14175','14176','14190','14192','14204','14206','14207','14218','14223','14231','14248','14249','14252','14258','14261','14266','14267','14272','14274','14280','14281','14286','14295','14297','14308','14319','14322','14324','14327','14328','14330','14332','14336','14337','14341','14351','14363','14369','14373','14376','14377','14378','14380','14381','14386','14390','14393','14398','14410','14417','14436','14438','14445','14447','14450','14451','14454','14457','14466','14467','14469','14472','14474','14480','14481','14485','14486','14495','14504','14509','14523','14526','14538','14555','14577','14595','14596','14602','14610','14611','14641','14646','14651','14652','14657','14688','14700','14707','14709','14722','14726','14727','14730','14735','14744','14750','14761','14766','14770','14778','14789','14795','14803','14804','14813','14820','14826','14837','14842','14849','14854','14856','14862','14874','14878','14879','14880','14909','14925','14931','14936','14945','14961','14966','14968','14975','14989','14991','14996','14999','15013','15024','15025','15047','15049','15060','15061','15064','15074','15088','15092','15105','15111','15112','15118','15119','15121','15123','15128','15135','15143','15155','15156','15164','15168','15172','15173','15175','15177','15181','15192','15196','15201','15203','15212','15213','15214','15216','15224','15229','15234','15235','15236','15250','15253','15255','15261','15262','15267','15274','15277','15287','15320','15321','15329','15331','15332','15338','15340','15341','15352','15356','15359','15369','15379','15381','15386','15390','15394','15399','15406','15412','15413','15423','15428','15433','15442','15448','15455','15456','15460','15472','15473','15491','15494','15512','15529','15538','15559','15570','15582','15586','15588','15591','15592','15599','15603','15605','15606','15610','15613','15631','15632','15656','15664','15665','15670','15671','15677','15685','15697','15703','15719','15725','15731','15736','15739','15745','15746','15752','15753','15759','15770','15773','15775','15778','15782','15785','15786','15792','15796','15801','15804','15809','15810','15815','15817','15821','15827','15832','15833','15849','15855','15858','15866','15874','15879','15884','15894','15896','15907','15908','15915','15916','15930','15943','15952','15955','15960','15962','15973','15976','15989','15995','16002','16003','16006','16007','16017','16023','16029','16047','16049','16058','16065','16075','16092','16101','16107','16108','16123','16138','16141','16144','16155','16159','16171','16188','16192','16200','16201','16205','16208','16209','16214','16215','16218','16220','16221','16223','16224','16232','16242','16243','16252','16255','16261','16266','16267','16270','16271','16272','16276','16277','16288','16290','16299','16303','16305','16306','16315','16336','16342','16349','16355','16362','16371','16377','16378','16386','16390','16391','16434','16442','16448','16452','16462','16463','16466','16468','16491','16500','16502','16504','16519','16524','16536','16539','16542','16549','16555','16561','16565','16570','16576','16579','16594','16599','16603','16604','16605','16622','16623','16629','16635','16639','16640','16649','16657','16659','16662','16663','16666','16670','16671','16679','16687','16694','16696','16698','16700','16715','16723','16731','16733','16739','16743','16754','16755','16758','16762','16777','16800','16803','16806','16809','16828','16845','16867','16870','16882','16883','16891','16906','16909','16912','16913','16919','16922','16925','16926','16945','16947','16949','16967','16978','16981','16987','16990','16998','17001','17011','17012','17022','17024','17025','17028','17038','17040','17041','17042','17048','17050','17056','17061','17067','17070','17073','17093','17094','17105','17107','17110','17112','17114','17118','17127','17135','17149','17156','17165','17168','17171','17175','17187','17188','17193','17194','17197','17207','17209','17211','17218','17219','17221','17222','17226','17229','17240','17247','17251','17253','17276','17283','17292','17295','17302','17304','17315','17324','17326','17329','17331','17336','17347','17351','17353','17362','17363','17370','17377','17386','17388','17390','17399','17403','17404','17405','17407','17408','17411','17419','17435','17437','17441','17451','17463','17475','17482','17484','17485','17491','17493','17496','17503','17505','17507','17509','17520','17521','17529','17534','17535','17547','17558','17560','17568','17570','17579','17584','17587','17596','17598','17600','17601','17602','17605','17616','17632','17639','17648','17649','17652','17656','17660','17680','17681','17684','17691','17700','17701','17706','17710','17724','17729','17741','17742','17747','17750','17757','17762','17774','17775','17782','17786','17790','17804','17813','17830','17831','17832','17833','17835','17837','17842','17843','17845','17846','17847','17851','17854','17858','17861','17863','17866','17887','17897','17914','17919','17921','17922','17933','17941','17950','17961','17968','17974','17983','17988','17989','17998','17999','18000','18006','18019','18025','18035','18036','18049','18050','18058','18069','18077','18078','18092','18098','18103','18105','18114','18118','18119','18125','18127','18136','18138','18144','18149','18153','18158','18163','18166','18176','18181','18184','18192','18196','18209','18228','18229','18235','18236','18246','18269','18272','18283','18288','18290','18293','18295','18312','18326','18332','18335','18337','18343','18345','18353','18358','18364','18380','18382','18396','18402','18403','18417','18423','18427','18432','18435','18441','18454','18457','18461','18481','18488','18489','18494','18495','18502','18506','18518','18535','18536','18549','18554','18559','18595','18596','18612','18623','18625','18628','18629','18634','18637','18642','18645','18656','18662','18664','18673','18687','18693','18702','18715','18716','18719','18720','18725','18730','18742','18743','18746','18748','18755','18757','18772','18775','18776','18781','18787','18788','18790','18797','18809','18811','18813','18816','18823','18825','18851','18858','18871','18872','18875','18891','18903','18906','18907','18908','18910','18913','18915','18920','18937','18941','18942','18943','18946','18948','18949','18954','18957','18958','18962','18964','18968','18976','18981','18988','18990','18996','19005','19014','19019','19023','19031','19037','19040','19042','19058','19068','19070','19074','19079','19086','19091','19094','19095','19105','19110','19112','19115','19121','19122','19123','19136','19145','19157','19165','19169','19171','19176','19181','19186','19189','19194','19197','19199','19207','19208','19214','19223','19225','19228','19237','19249','19252','19255','19264','19268','19269','19270','19274','19295','19301','19307','19308','19314','19317','19318','19321','19323','19324','19335','19337','19339','19343','19348','19349','19353','19358','19364','19371','19382','19384','19385','19395','19398','19402','19405','19422','19430','19447','19448','19453','19454','19456','19465','19466','19476','19478','19484','19486','19488','19490','19501','19506','19514','19519','19521','19522','19527','19539','19540','19553','19555','19557','19564','19577','19579','19580','19590','19604','19612','19614','19623','19631','19634','19642','19648','19651','19654','19655','19656','19668','19677','19682','19686','19695','19721','19724','19730','19749','19751','19753','19755','19759','19762','19766','19767','19768','19772','19778','19791','19807','19812','19818','19829','19836','19838','19843','19847','19848','19850','19852','19853','19854','19858','19861','19868','19870','19878','19884','19910','19914','19918','19921','19922','19925','19928','19942','19943','19947','19950','19959','19971','19977','19981','19985','19986','19994','20000','20003','20007','20008','20015','20028','20029','20041','20056','20063','20069','20075','20078','20083','20085','20089','20091','20098','20105','20128','20129','20143','20146','20153','20154','20156','20159','20170','20180','20181','20182','20183','20188','20189','20195','20200','20204','20209','20216','20218','20221','20224','20229','20233','20234','20237','20239','20241','20253','20256','20260','20263','20264','20265','20268','20271','20274','20289','20290','20291','20304','20306','20307','20308','20311','20317','20324','20339','20348','20350','20357','20363','20369','20370','20376','20379','20387','20388','20403','20404','20407','20413','20415','20425','20433','20437','20440','20442','20443','20444','20446','20448','20450','20458','20464','20481','20489','20495','20496','20511','20512','20513','20514','20517','20522','20534','20535','20540','20541','20550','20555','20556','20558','20561','20569','20570','20573','20582','20613','20614','20623','20631','20637','20643','20647','20669','20686','20695','20696','20705','20707','20716','20718','20724','20728','20729','20736','20738','20742','20748','20761','20779','20782','20785','20793','20812','20814','20840','20846','20848','20853','20857','20872','20875','20880','20881','20885','20891','20899','20914','20917','20924','20937','20943','20944','20947','20959','20970','20974','20982','20984','20985','20986','21003','21006','21013','21028','21032','21036','21047','21054','21056','21057','21058','21079','21087','21094','21097','21102','21111','21113','21118','21120','21131','21138','21153','21154','21167','21168','21170','21172','21186','21187','21191','21202','21213','21216','21217','21220','21227','21238','21241','21247','21249','21271','21281','21290','21300','21304','21306','21312','21316','21318','21320','21328','21334','21337','21338','21348','21350','21352','21356','21399','21403','21423','21424','21435','21441','21449','21455','21463','21478','21481','21482','21486','21487','21491','21494','21509','21510','21512','21518','21521','21523','21529','21530','21532','21533','21535','21537','21549','21577','21578','21579','21583','21587','21598','21604','21613','21623','21632','21641','21643','21652','21655','21656','21659','21671','21673','21674','21683','21684','21690','21697','21713','21716','21721','21725','21727','21733','21734','21735','21737','21745','21746','21751','21753','21758','21775','21779','21788','21789','21793','21795','21800','21809','21813','21814','21826','21831','21850','21858','21862','21869','21873','21875','21877','21880','21886','21892','21893','21896','21898','21900','21903','21917','21919','21923','21926','21934','21936','21938','21940','21950','21952','21961','21968','21972','21978','21985','21994','22002','22008','22009','22011','22014','22015','22017','22019','22026','22032','22045','22065','22067','22079','22088','22096','22105','22107','22109','22111','22116','22123','22136','22146','22150','22161','22176','22184','22196','22201','22209','22212','22215','22217','22223','22224','22229','22232','22234','22235','22236','22249','22252','22255','22259','22262','22268','22269','22272','22276','22278','22292','22308','22310','22312','22315','22316','22326','22338','22340','22341','22342','22347','22351','22368','22374','22386','22389','22393','22397','22399','22400','22412','22414','22421','22426','22441','22442','22443','22446','22449','22465','22467','22490','22492','22494','22497','22499','22506','22508','22512','22516','22519','22522','22527','22548','22552','22554','22559','22569','22574','22575','22576','22581','22583','22586','22593','22604','22609','22610','22617','22623','22625','22633','22634','22637','22638','22640','22642','22645','22647','22651','22661','22662','22665','22666','22677','22678','22681','22682','22683','22685','22694','22695','22701','22702','22708','22713','22724','22726','22729','22731','22741','22745','22747','22748','22761','22782','22784','22795','22796','22798','22800','22804','22823','22833','22835','22844','22847','22850','22854','22857','22858','22864','22872','22875','22883','22891','22902','22904','22911','22934','22954','22970','22972','22974','22983','22993','23007','23009','23012','23013','23017','23023','23037','23046','23047','23048','23049','23061','23072','23083','23091','23109','23113','23114','23115','23116','23125','23127','23128','23133','23140','23143','23145','23147','23154','23160','23173','23180','23182','23186','23187','23204','23207','23211','23215','23217','23223','23224','23239','23257','23266','23268','23275','23277','23282','23287','23288','23289','23290','23301','23302','23306','23314','23315','23319','23322','23331','23336','23341','23344','23345','23348','23350','23354','23355','23365','23368','23369','23371','23372','23375','23381','23387','23394','23395','23398','23408','23415','23435','23438','23448','23453','23454','23462','23465','23466','23478','23481','23486','23490','23491','23498','23516','23519','23528','23536','23537','23541','23544','23549','23550','23553','23554','23555','23557','23560','23568','23569','23570','23578','23587','23588','23595','23597','23602','23605','23613','23615','23619','23620','23626','23627','23631','23638','23648','23654','23655','23658','23665','23668','23680','23700','23707','23711','23718','23722','23723','23725','23727','23731','23734','23740','23747','23759','23764','23766','23784','23786','23790','23794','23802','23811','23814','23819','23821','23827','23830','23834','23843','23846','23861','23863','23865','23867','23870','23875','23896','23898','23899','23910','23911','23912','23920','23938','23939','23946','23949','23971','23972','23975','23977','23981','23984','23987','23997','24002','24003','24009','24012','24023','24024','24031','24034','24043','24048','24051','24056','24062','24070','24074','24077','24079','24091','24094','24095','24109','24110','24113','24116','24122','24125','24128','24129','24136','24141','24148','24150','24152','24160','24161','24162','24163','24166','24170','24171','24172','24175','24179','24181','24183','24196','24210','24211','24225','24232','24241','24244','24245','24249','24250','24258','24262','24267','24270','24272','24274','24279','24295','24303','24304','24313','24320','24321','24326','24328','24332','24335','24340','24347','24349','24354','24355','24356','24358','24362','24365','24367','24373','24374','24377','24386','24389','24405','24407','24426','24430','24432','24441','24445','24447','24448','24473','24479','24485','24486','24490','24495','24496','24506','24512','24514','24516','24526','24536','24540','24544','24546','24565','24569','24576','24578','24582','24583','24584','24585','24587','24592','24595','24599','24600','24603','24608','24618','24624','24625','24626','24633','24639','24641','24645','24649','24665','24668','24673','24678','24679','24687','24689','24695','24696','24699','24705','24708','24711','24714','24715','24716','24719','24720','24721','24747','24751','24755','24780','24784','24787','24789','24792','24797','24817','24824','24825','24826','24827','24828','24837','24845','24858','24869','24875','24892','24896','24899','24907','24908','24909','24910','24911','24913','24914','24916','24921','24933','24935','24953','24954','24955','24958','24965','24968','24994','25002','25012','25014','25016','25021','25028','25032','25051','25054','25056','25057','25061','25076','25085','25089','25091','25092','25097','25098','25107','25112','25114','25116','25117','25125','25128','25133','25137','25142','25144','25146','25148','25159','25160','25166','25167','25170','25180','25181','25185','25186','25197','25198','25203','25204','25211','25227','25229','25232','25235','25239','25242','25244','25245','25259','25261','25263','25268','25272','25282','25284','25289','25290','25291','25294','25297','25300','25303','25306','25322','25323','25326','25332','25333','25337','25339','25349','25351','25352','25354','25358','25360','25362','25394','25395','25398','25401','25402','25403','25408','25409','25416','25429','25435','25450','25451','25452','25458','25459','25486','25491','25495','25496','25503','25505','25508','25513','25514','25519','25520','25522','25524','25526','25528','25530','25534','25535','25544','25556','25558','25560','25563','25571','25572','25578','25581','25586','25595','25598','25599','25600','25601','25617','25622','25631','25638','25640','25641','25644','25648','25649','25650','25652','25654','25660','25669','25673','25676','25699','25700','25701','25705','25708','25721','25723','25730','25735','25739','25745','25755','25765','25770','25773','25777','25782','25797','25800','25803','25820','25825','25829','25830','25835','25848','25856','25858','25859','25861','25869','25875','25881','25885','25890','25891','25896','25897','25899','25911','25913','25921','25922','25923','25925','25926','25932','25934','25940','25942','25946','25954','25959','25960','25971','25983','25985','26012','26015','26018','26024','26034','26041','26049','26053','26055','26058','26062','26074','26079','26090','26098','26118','26123','26141','26154','26155','26156','26159','26163','26166','26182','26184','26185','26187','26190','26198','26205','26212','26217','26228','26229','26230','26232','26237','26239','26243','26252','26253','26254','26255','26257','26263','26264','26265','26272','26273','26284','26291','26297','26324','26335','26338','26346','26352','26361','26371','26375','26376','26379','26380','26384','26391','26394','26395','26403','26404','26412','26420','26425','26432','26434','26436','26438','26444','26447','26449','26472','26478','26481','26497','26498','26500','26501','26508','26513','26514','26521','26523','26524','26525','26533','26536','26549','26555','26558','26560','26583','26585','26586','26598','26613','26617','26623','26633','26649','26652','26675','26676','26678','26680','26686','26692','26694','26696','26700','26703','26706','26710','26712','26716','26717','26718','26720','26721','26724','26728','26730','26733','26746','26754','26758','26759','26766','26767','26769','26781','26790','26797','26802','26815','26818','26824','26830','26837','26842','26856','26858','26864','26872','26874','26875','26876','26882','26883','26885','26887','26889','26894','26895','26930','26937','26939','26945','26960','26976','26979','26980','26983','26985','26990','27002','27011','27012','27014','27034','27036','27037','27046','27048','27053','27058','27064','27088','27094','27106','27111','27118','27121','27122','27127','27131','27133','27137','27142','27144','27145','27146','27148','27150','27152','27153','27154','27158','27165','27166','27172','27173','27175','27179','27189','27194','27197','27203','27206','27225','27229','27242','27246','27256','27272','27274','27286','27288','27297','27303','27313','27316','27317','27319','27322','27323','27324','27325','27327','27330','27334','27354','27359','27365','27367','27381','27382','27383','27388','27395','27396','27400','27407','27408','27411','27415','27422','27428','27429','27437','27442','27447','27453','27455','27457','27467','27470','27479','27487','27489','27490','27499','27506','27511','27513','27516','27517','27521','27525','27534','27539','27546','27549','27554','27555','27558','27560','27566','27573','27574','27582','27589','27593','27595','27601','27607','27612','27623','27626','27630','27631','27637','27638','27641','27642','27644','27645','27646','27653','27655','27662','27663','27681','27684','27693','27696','27698','27707','27708','27711','27715','27719','27722','27724','27728','27729','27739','27750','27756','27768','27769','27773','27777','27785','27791','27800','27803','27804','27808','27809','27810','27813','27819','27821','27824','27830','27844','27845','27846','27853','27857','27870','27872','27882','27888','27891','27900','27907','27908','27914','27915','27917','27925','27927','27930','27932','27933','27935','27936','27937','27939','27940','27941','27943','27949','27955','27960','27962','27966','27969','27976','27978','27986','28009','28013','28017','28026','28028','28030','28032','28033','28036','28041','28044','28045','28047','28051','28058','28063','28064','28066','28068','28069','28070','28073','28083','28085','28090','28094','28097','28100','28109','28111','28118','28119','28120','28132','28138','28142','28143','28147','28158','28162','28164','28169','28174','28175','28181','28186','28189','28190','28192','28195','28201','28214','28224','28226','28227','28231','28245','28251','28258','28262','28270','28274','28284','28290','28292','28298','28307','28323','28327','28330','28337','28339','28340','28346','28375','28376','28384','28386','28389','28394','28395','28398','28414','28415','28421','28424','28434','28444','28455','28464','28473','28476','28479','28481','28483','28484','28485','28490','28491','28494','28508','28509','28523','28524','28526','28545','28548','28549','28556','28558','28568','28572','28578','28579','28582','28590','28591','28596','28600','28603','28613','28616','28618','28620','28623','28634','28635','28640','28641','28643','28651','28659','28660','28661','28665','28668','28669','28680','28686','28693','28694','28695','28700','28701','28703','28704','28711','28712','28720','28724','28736','28740','28741','28742','28746','28747','28751','28756','28758','28767','28769','28773','28775','28777','28778','28791','28808','28817','28819','28822','28823','28831','28835','28841','28845','28847','28850','28852','28856','28862','28865','28867','28869','28872','28880','28897','28899','28901','28907','28908','28913','28914','28915','28923','28926','28934','28939','28940','28945','28947','28948','28949','28964','28967','28972','28987','28990','29002','29005','29012','29018','29026','29033','29035','29038','29039','29040','29054','29058','29065','29069','29070','29079','29083','29090','29095','29108','29109','29112','29115','29120','29125','29127','29136','29139','29141','29143','29145','29146','29157','29162','29163','29178','29190','29193','29200','29207','29208','29212','29222','29223','29227','29229','29235','29236','29238','29242','29250','29252','29260','29266','29271','29273','29281','29282','29289','29295','29296','29301','29305','29306','29308','29310','29314','29316','29323','29329','29332','29335','29336','29338','29344','29346','29347','29351','29352','29356','29360','29364','29369','29370','29375','29376','29382','29391','29394','29406','29407','29410','29423','29437','29441','29444','29446','29449','29453','29454','29468','29469','29471','29474','29477','29479','29480','29481','29487','29504','29510','29516','29522','29527','29537','29538','29539','29543','29552','29554','29555','29556','29562','29569','29571','29575','29576','29579','29587','29592','29594','29595','29615','29622','29623','29624','29625','29630','29631','29632','29635','29640','29642','29647','29648','29650','29659','29663','29671','29675','29684','29693','29694','29700','29701','29706','29722','29729','29731','29732','29735','29740','29751','29757','29759','29761','29763','29769','29770','29771','29779','29780','29783','29785','29787','29788','29793','29794','29795','29797','29808','29811','29813','29831','29833','29839','29842','29847','29848','29851','29866','29867','29870','29877','29881','29883','29884','29893','29898','29905','29908','29911','29914','29916','29918','29920','29926','29939','29953','29956','29965','29978','29985','29992','29997','30009','30011','30017','30026','30027','30029','30031','30034','30040','30044','30045','30047','30048','30054','30063','30064','30068','30071','30074','30077','30079','30081','30096','30098','30101','30104','30111','30116','30129','30131','30141','30147','30156','30160','30162','30169','30171','30175','30178','30185','30186','30191','30192','30193','30198','30201','30203','30204','30209','30220','30222','30233','30239','30246','30248','30249','30255','30257','30258','30260','30269','30271','30274','30279','30280','30281','30283','30287','30288','30296','30300','30308','30309','30324','30328','30331','30333','30335','30339','30341','30343','30344','30346','30348','30352','30356','30358','30362','30372','30375','30378','30379','30388','30394','30400','30404','30422','30435','30440','30445','30447','30449','30458','30462','30474','30480','30488','30489','30500','30501','30503','30504','30506','30507','30509','30516','30521','30524','30528','30529','30538','30540','30548','30549','30558','30560','30562','30575','30583','30587','30591','30595','30596','30598','30605','30606','30609','30610','30611','30613','30618','30627','30628','30629','30635','30641','30645','30646','30659','30660','30669','30670','30680','30682','30683','30690','30692','30696','30697','30701','30703','30704','30708','30715','30717','30733','30740','30749','30751','30754','30760','30762','30765','30766','30768','30770','30772','30777','30784','30787','30792','30799','30807','30808','30811','30815','30817','30818','30822','30833','30836','30837','30852','30853','30854','30864','30870','30873','30881','30883','30885','30888','30890','30896','30904','30905','30908','30909','30916','30920','30925','30926','30927','30935','30936','30943','30955','30956','30962','30971','30974','30975','30979','30981','30982','30983','30988','30989','31006','31010','31022','31025','31032','31037','31038','31042','31052','31053','31056','31061','31064','31066','31075','31086','31091','31094','31097','31098','31102','31112','31120','31121','31125','31133','31137','31158','31165','31174','31177','31183','31186','31194','31195','31196','31201','31204','31207','31213','31214','31218','31220','31221','31226','31229','31231','31235','31238','31245','31249','31252','31253','31259','31260','31269','31277','31279','31280','31285','31286','31288','31289','31295','31297','31298','31316','31327','31328','31336','31343','31349','31355','31359','31364','31365','31368','31371','31375','31381','31385','31387','31392','31393','31398','31400','31402','31406','31413','31431','31437','31441','31447','31453','31458','31463','31473','31493','31494','31496','31497','31498','31501','31504','31507','31510','31520','31521','31525','31526','31537','31544','31545','31547','31551','31554','31558','31561','31562','31568','31575','31579','31580','31582','31583','31585','31590','31608','31609','31620','31621','31622','31626','31628','31629','31630','31633','31640','31641','31643','31646','31650','31653','31663','31668','31684','31689','31696','31701','31704','31715','31728','31729','31731','31735','31739','31741','31742','31744','31745','31747','31754','31756','31762','31769','31770','31773','31774','31776','31777','31787','31790','31795','31803','31806','31817','31818','31824','31825','31826','31835','31840','31842','31844','31847','31850','31851','31860','31862','31871','31872','31888','31897','31911','31921','31923','31933','31935','31946','31949','31951','31956','31961','31975','31977','31983','31984','31987','31991','32001','32006','32014','32022','32025','32033','32037','32038','32045','32053','32060','32065','32067','32071','32072','32076','32077','32081','32082','32088','32092','32100','32102','32103','32109','32113','32118','32123','32128','32132','32134','32135','32138','32140','32142','32143','32146','32150','32151','32153','32157','32160','32161','32162','32166','32187','32191','32192','32193','32195','32202','32205','32206','32211','32213','32215','32217','32223','32238','32240','32242','32243','32247','32250','32252','32276','32280','32282','32283','32286','32295','32301','32304','32310','32311','32312','32323','32324','32326','32336','32343','32346','32348','32351','32356','32360','32361','32362','32365','32368','32372','32374','32376','32382','32392','32399','32402','32416','32417','32418','32421','32426','32438','32450','32455','32456','32457','32459','32461','32469','32470','32479','32480','32485','32489','32494','32501','32503','32511','32512','32518','32519','32520','32523','32525','32529','32536','32538','32542','32544','32551','32580','32585','32587','32592','32595','32596','32604','32616','32618','32622','32623','32624','32626','32629','32633','32636','32643','32647','32650','32654','32662','32683','32686','32690','32699','32701','32705','32707','32724','32728','32733','32735','32749','32772','32777','32786','32789','32795','32796','32800','32815','32818','32819','32823','32825','32829','32830','32834','32835','32840','32841','32855','32857','32865','32868','32869','32871','32873','32880','32883','32889','32891','32892','32893','32894','32900','32931','32939','32945','32946','32951','32958','32964','32974','32975','32976','32977','32980','32982','32985','33001','33002','33003','33008','33009','33012','33014','33015','33019','33027','33031','33033','33042','33044','33045','33049','33055','33069','33083','33089','33093','33094','33109','33115','33116','33124','33125','33126','33135','33144','33149','33165','33173','33185','33210','33229','33234','33235','33240','33264','33271','33278','33288','33289','33291','33295','33303','33304','33305','33333','33335','33336','33346','33355','33376','33384')

Which gave the following error:

An error occurred when executing the query.
The data provider said:
OGR[3] error 1: SQL Expression Parsing Error: memory exhausted. Occured around :
'30171','30175','30178','30185','30186','30191','30192','30193','30198','30201',
                                        ^

By splitting the IN clause in two parts with an "OR", by writing "id IN (...) OR "id IN (...), I managed to get my query working:

"id" IN ('0-E','1','6','14','23','25','38','49','51','61','81','85','90','93','114','138','143','144','148','158','159','168','176','182','185','195','212','220','222','223','227','233','235','246','248','255','261','262','293','295','301','323','328','330','338','341','347','352','361','365','366','371','372','375','382','387','400','404','406','413','421','424','426','428','433','434','436','444','455','471','474','478','485','486','513','529','532','534','538','548','557','560','562','565','571','584','587','589','593','602','604','609','619','631','649','653','668','672','673','681','685','686','694','703','704','706','707','711','716','731','734','741','752','757','765','777','782','786','791','796','799','805','807','814','821','823','831','836','839','849','867','871','884','888','890','892','894','896','914','915','928','935','936','955','961','966','971','972','976','977','1000','1014','1035','1038','1046','1047','1049','1097','1100','1101','1105','1110','1115','1117','1120','1121','1122','1130','1133','1160','1174','1177','1187','1195','1209','1223','1229','1232','1243','1260','1261','1262','1268','1279','1291','1299','1306','1307','1310','1312','1315','1318','1323','1326','1332','1340','1351','1354','1372','1381','1392','1393','1396','1413','1418','1428','1432','1438','1445','1446','1449','1453','1461','1466','1482','1489','1501','1502','1505','1513','1520','1528','1532','1537','1539','1545','1547','1556','1560','1561','1564','1567','1570','1578','1584','1587','1592','1594','1595','1597','1603','1614','1622','1643','1655','1659','1660','1667','1680','1685','1687','1688','1696','1697','1701','1737','1756','1757','1767','1777','1789','1790','1797','1814','1815','1826','1827','1836','1840','1842','1843','1844','1846','1853','1863','1864','1867','1878','1881','1883','1889','1894','1899','1903','1926','1927','1928','1936','1948','1957','1964','1980','2003','2005','2018','2025','2026','2033','2043','2044','2055','2057','2062','2072','2073','2074','2079','2088','2089','2092','2095','2101','2107','2119','2131','2153','2156','2157','2162','2171','2176','2187','2190','2196','2198','2209','2242','2256','2265','2285','2287','2288','2290','2299','2318','2319','2324','2340','2342','2363','2365','2373','2374','2377','2383','2387','2395','2402','2413','2414','2421','2433','2441','2453','2467','2478','2481','2483','2487','2499','2503','2514','2533','2544','2546','2550','2556','2565','2567','2573','2574','2577','2582','2588','2589','2598','2603','2610','2614','2615','2620','2632','2640','2663','2664','2684','2714','2722','2725','2726','2748','2750','2758','2761','2764','2775','2778','2786','2788','2790','2806','2814','2815','2817','2820','2829','2834','2837','2856','2875','2881','2898','2902','2908','2932','2948','2949','2955','2959','2969','2973','2979','3000','3001','3003','3009','3015','3018','3019','3038','3055','3057','3071','3081','3082','3092','3093','3094','3117','3119','3127','3132','3133','3140','3160','3165','3184','3188','3195','3200','3205','3215','3216','3226','3229','3230','3236','3255','3256','3259','3260','3287','3288','3297','3323','3325','3329','3331','3340','3345','3358','3365','3372','3376','3384','3388','3404','3405','3421','3423','3430','3450','3460','3468','3476','3477','3483','3487','3497','3499','3500','3508','3514','3515','3516','3527','3532','3533','3555','3576','3585','3602','3603','3631','3641','3643','3646','3648','3649','3651','3652','3658','3671','3673','3681','3687','3688','3693','3702','3713','3716','3719','3723','3762','3765','3769','3777','3786','3793','3802','3803','3807','3808','3814','3816','3821','3826','3829','3831','3837','3839','3841','3842','3845','3852','3855','3856','3860','3865','3869','3872','3877','3888','3889','3899','3903','3905','3916','3918','3926','3929','3941','3947','3950','3953','3962','3970','3982','4015','4018','4030','4031','4040','4041','4044','4050','4055','4069','4071','4072','4076','4084','4085','4087','4093','4095','4106','4109','4113','4118','4119','4121','4124','4125','4129','4153','4156','4165','4174','4180','4192','4208','4214','4220','4225','4228','4231','4240','4268','4277','4281','4294','4295','4297','4303','4318','4324','4325','4326','4327','4337','4343','4345','4351','4354','4359','4364','4365','4388','4392','4398','4404','4405','4424','4431','4445','4458','4466','4468','4470','4472','4480','4487','4492','4493','4498','4499','4504','4510','4513','4521','4531','4543','4546','4549','4552','4556','4557','4558','4561','4562','4576','4583','4586','4597','4614','4617','4627','4646','4649','4654','4664','4668','4714','4723','4728','4752','4760','4761','4763','4767','4772','4791','4814','4823','4825','4840','4841','4847','4850','4865','4873','4884','4893','4895','4905','4918','4920','4935','4936','4943','4953','4964','4969','4978','4979','4980','4994','5003','5015','5017','5019','5021','5028','5030','5033','5039','5041','5042','5046','5050','5052','5053','5062','5064','5072','5079','5083','5087','5098','5111','5113','5119','5121','5147','5148','5154','5157','5159','5178','5185','5186','5192','5193','5201','5223','5238','5240','5251','5253','5260','5280','5288','5296','5297','5305','5306','5310','5313','5316','5319','5327','5329','5346','5347','5348','5362','5370','5371','5372','5382','5400','5411','5416','5427','5433','5438','5440','5444','5447','5453','5458','5459','5461','5465','5472','5474','5475','5483','5487','5494','5504','5507','5527','5536','5539','5542','5548','5561','5563','5564','5569','5571','5581','5584','5587','5588','5604','5609','5610','5614','5635','5642','5652','5653','5662','5669','5673','5678','5683','5691','5693','5695','5699','5704','5730','5732','5735','5743','5748','5758','5765','5766','5768','5770','5774','5779','5792','5811','5814','5819','5829','5830','5831','5856','5862','5875','5876','5879','5883','5885','5899','5903','5907','5908','5913','5921','5934','5941','5948','5953','5960','5964','5969','5973','5981','5985','5992','5993','5996','5998','6002','6004','6008','6015','6018','6020','6028','6034','6036','6048','6049','6059','6067','6073','6081','6084','6086','6093','6114','6122','6130','6137','6138','6142','6143','6157','6163','6165','6167','6178','6187','6192','6195','6201','6205','6206','6209','6218','6230','6245','6254','6260','6264','6275','6280','6281','6284','6305','6308','6312','6325','6326','6334','6359','6360','6362','6367','6373','6379','6389','6390','6394','6403','6417','6420','6423','6438','6443','6451','6459','6463','6466','6468','6470','6477','6482','6491','6500','6505','6509','6514','6518','6520','6525','6528','6541','6544','6547','6551','6559','6574','6585','6589','6594','6606','6609','6619','6627','6661','6668','6670','6671','6674','6680','6688','6696','6699','6707','6713','6718','6724','6745','6751','6755','6773','6781','6798','6810','6812','6844','6859','6860','6877','6878','6879','6888','6889','6891','6893','6901','6909','6912','6925','6926','6932','6935','6942','6943','6950','6957','6970','6976','6981','6987','6989','6990','6991','6997','7001','7005','7026','7027','7035','7048','7053','7057','7059','7061','7064','7080','7083','7089','7090','7091','7092','7094','7096','7104','7106','7108','7111','7112','7115','7129','7137','7144','7155','7157','7167','7177','7180','7200','7202','7214','7232','7235','7238','7248','7252','7256','7268','7272','7287','7292','7301','7322','7324','7326','7331','7333','7346','7349','7356','7359','7361','7371','7376','7377','7387','7388','7394','7401','7426','7427','7432','7435','7437','7438','7445','7446','7451','7454','7468','7485','7486','7514','7517','7536','7540','7544','7551','7555','7557','7572','7577','7589','7604','7606','7626','7627','7633','7642','7643','7652','7654','7668','7690','7696','7697','7702','7717','7721','7743','7746','7748','7749','7750','7751','7760','7764','7765','7772','7777','7779','7808','7813','7828','7863','7870','7876','7884','7889','7897','7898','7900','7903','7911','7912','7919','7922','7925','7934','7936','7944','7945','7947','7962','7964','7969','7975','7978','7990','7994','8000','8015','8023','8028','8035','8040','8041','8048','8051','8055','8056','8057','8062','8071','8080','8083','8086','8097','8102','8106','8113','8120','8135','8139','8152','8164','8172','8174','8175','8178','8182','8191','8199','8205','8210','8211','8216','8221','8223','8224','8232','8240','8241','8252','8275','8292','8303','8306','8307','8321','8326','8335','8350','8358','8365','8374','8376','8386','8387','8396','8398','8404','8411','8433','8443','8456','8458','8479','8482','8489','8496','8499','8504','8511','8521','8523','8524','8529','8530','8534','8538','8548','8549','8555','8558','8561','8562','8571','8579','8589','8593','8606','8614','8628','8629','8638','8640','8653','8661','8669','8676','8694','8698','8720','8723','8729','8733','8742','8745','8752','8756','8758','8763','8774','8791','8795','8809','8816','8820','8821','8836','8837','8838','8840','8845','8849','8851','8853','8856','8865','8867','8877','8878','8892','8901','8906','8912','8914','8915','8923','8941','8946','8956','8972','8981','8986','8991','8992','9007','9023','9026','9039','9041','9049','9074','9077','9086','9096','9101','9106','9114','9120','9132','9135','9137','9138','9159','9161','9164','9183','9189','9204','9210','9217','9220','9226','9228','9231','9236','9237','9239','9243','9245','9248','9250','9260','9262','9264','9274','9277','9299','9310','9311','9314','9316','9336','9356','9365','9367','9368','9370','9374','9378','9393','9398','9411','9415','9439','9440','9452','9468','9470','9474','9476','9477','9484','9493','9507','9516','9517','9534','9538','9542','9554','9557','9569','9570','9579','9587','9602','9613','9626','9636','9672','9691','9713','9725','9739','9744','9747','9754','9758','9760','9763','9765','9772','9775','9778','9779','9792','9801','9818','9826','9864','9871','9875','9876','9920','9921','9923','9929','9939','9943','9949','9953','9957','9971','9984','9991','10007','10010','10017','10020','10026','10027','10034','10046','10053','10055','10058','10060','10061','10063','10067','10077','10078','10095','10101','10106','10132','10133','10135','10140','10149','10150','10157','10160','10163','10181','10190','10192','10208','10221','10226','10243','10251','10256','10271','10274','10279','10289','10296','10305','10314','10348','10368','10372','10373','10379','10388','10403','10417','10428','10429','10432','10433','10435','10436','10442','10444','10449','10452','10453','10456','10460','10472','10495','10504','10513','10540','10546','10551','10561','10580','10586','10587','10589','10599','10612','10632','10642','10644','10645','10647','10660','10679','10681','10682','10684','10685','10687','10692','10693','10697','10709','10715','10720','10738','10745','10748','10751','10760','10762','10773','10788','10797','10798','10800','10819','10820','10826','10830','10859','10860','10863','10867','10877','10884','10895','10896','10902','10909','10910','10911','10912','10914','10916','10918','10921','10924','10937','10941','10968','10980','10981','10984','10987','10988','10993','10997','11003','11023','11026','11051','11056','11066','11077','11082','11086','11091','11092','11102','11108','11110','11118','11128','11138','11141','11146','11174','11177','11180','11194','11195','11205','11208','11213','11217','11220','11224','11243','11244','11253','11255','11262','11270','11272','11285','11287','11296','11297','11301','11307','11308','11318','11321','11339','11346','11356','11364','11366','11370','11375','11377','11380','11404','11405','11410','11414','11417','11446','11448','11451','11459','11464','11476','11479','11502','11512','11515','11537','11541','11542','11544','11551','11563','11565','11578','11581','11585','11592','11595','11599','11600','11605','11618','11630','11637','11643','11648','11652','11654','11657','11664','11667','11671','11674','11677','11678','11688','11698','11699','11701','11705','11707','11710','11721','11724','11728','11736','11751','11757','11758','11762','11771','11780','11783','11784','11796','11798','11801','11809','11813','11821','11826','11844','11845','11848','11854','11858','11863','11864','11867','11871','11874','11891','11892','11894','11897','11902','11907','11910','11912','11914','11917','11943','11947','11950','11958','11967','11999','12023','12028','12036','12039','12060','12066','12074','12076','12080','12082','12086','12087','12096','12106','12115','12120','12126','12136','12139','12143','12150','12155','12159','12164','12182','12193','12195','12196','12205','12213','12238','12242','12244','12253','12257','12271','12281','12284','12292','12295','12301','12318','12329','12337','12338','12352','12360','12363','12364','12374','12382','12401','12432','12438','12440','12443','12444','12455','12459','12461','12464','12486','12491','12498','12510','12513','12514','12534','12537','12539','12540','12551','12564','12567','12573','12574','12581','12584','12586','12600','12603','12611','12615','12625','12629','12638','12642','12656','12659','12661','12671','12677','12678','12684','12692','12693','12695','12697','12716','12724','12735','12756','12775','12787','12790','12805','12809','12824','12835','12837','12844','12845','12857','12861','12868','12876','12880','12881','12884','12893','12903','12908','12923','12926','12935','12940','12947','12953','12956','12965','12977','12979','12980','12984','12992','12996','12998','13002','13012','13027','13062','13066','13081','13087','13100','13103','13106','13107','13117','13120','13123','13131','13146','13148','13149','13154','13160','13162','13166','13170','13184','13185','13186','13190','13192','13193','13196','13215','13216','13218','13219','13230','13238','13239','13244','13247','13253','13259','13265','13266','13269','13282','13285','13286','13289','13300','13301','13307','13312','13313','13318','13320','13331','13332','13357','13358','13366','13367','13375','13389','13407','13408','13409','13410','13416','13429','13433','13438','13440','13459','13465','13470','13475','13481','13482','13483','13486','13487','13490','13502','13505','13506','13510','13514','13527','13540','13545','13546','13547','13564','13565','13566','13570','13572','13576','13578','13580','13581','13583','13585','13591','13593','13595','13597','13601','13606','13611','13619','13624','13631','13635','13637','13638','13639','13651','13660','13678','13683','13686','13726','13729','13732','13737','13738','13741','13742','13756','13759','13762','13765','13769','13770','13775','13784','13792','13805','13808','13820','13827','13834','13841','13855','13857','13862','13868','13871','13881','13882','13889','13891','13896','13905','13911','13913','13926','13929','13932','13942','13962','13989','13990','13994','13995','13997','14003','14004','14006','14007','14010','14013','14015','14017','14019','14024','14026','14030','14033','14034','14069','14075','14078','14080','14081','14082','14085','14089','14090','14091','14093','14097','14099','14106','14107','14113','14116','14135','14147','14149','14153','14158','14160','14168','14169','14175','14176','14190','14192','14204','14206','14207','14218','14223','14231','14248','14249','14252','14258','14261','14266','14267','14272','14274','14280','14281','14286','14295','14297','14308','14319','14322','14324','14327','14328','14330','14332','14336','14337','14341','14351','14363','14369','14373','14376','14377','14378','14380','14381','14386','14390','14393','14398','14410','14417','14436','14438','14445','14447','14450','14451','14454','14457','14466','14467','14469','14472','14474','14480','14481','14485','14486','14495','14504','14509','14523','14526','14538','14555','14577','14595','14596','14602','14610','14611','14641','14646','14651','14652','14657','14688','14700','14707','14709','14722','14726','14727','14730','14735','14744','14750','14761','14766','14770','14778','14789','14795','14803','14804','14813','14820','14826','14837','14842','14849','14854','14856','14862','14874','14878','14879','14880','14909','14925','14931','14936','14945','14961','14966','14968','14975','14989','14991','14996','14999','15013','15024','15025','15047','15049','15060','15061','15064','15074','15088','15092','15105','15111','15112','15118','15119','15121','15123','15128','15135','15143','15155','15156','15164','15168','15172','15173','15175','15177','15181','15192','15196','15201','15203','15212','15213','15214','15216','15224','15229','15234','15235','15236','15250','15253','15255','15261','15262','15267','15274','15277','15287','15320','15321','15329','15331','15332','15338','15340','15341','15352','15356','15359','15369','15379','15381','15386','15390','15394','15399','15406','15412','15413','15423','15428','15433','15442','15448','15455','15456','15460','15472','15473','15491','15494','15512','15529','15538','15559','15570','15582','15586','15588','15591','15592','15599','15603','15605','15606','15610','15613','15631','15632','15656','15664','15665','15670','15671','15677','15685','15697','15703','15719','15725','15731','15736','15739','15745','15746','15752','15753','15759','15770','15773','15775','15778','15782','15785','15786','15792','15796','15801','15804','15809','15810','15815','15817','15821','15827','15832','15833','15849','15855','15858','15866','15874','15879','15884','15894','15896','15907','15908','15915','15916','15930','15943','15952','15955','15960','15962','15973','15976','15989','15995','16002','16003','16006','16007','16017','16023','16029','16047','16049','16058','16065','16075','16092','16101','16107','16108','16123','16138','16141','16144','16155','16159','16171','16188','16192','16200','16201','16205','16208','16209','16214','16215','16218','16220','16221','16223','16224','16232','16242','16243','16252','16255','16261','16266','16267','16270','16271','16272','16276','16277','16288','16290','16299','16303','16305','16306','16315','16336','16342','16349','16355','16362','16371','16377','16378','16386','16390','16391','16434','16442','16448','16452','16462','16463','16466','16468','16491','16500','16502','16504','16519','16524','16536','16539','16542','16549','16555','16561','16565','16570','16576','16579','16594','16599','16603','16604','16605','16622','16623','16629','16635','16639','16640','16649','16657','16659','16662','16663','16666','16670','16671','16679','16687','16694','16696','16698','16700','16715','16723','16731','16733','16739','16743','16754','16755','16758','16762','16777','16800','16803','16806','16809','16828','16845','16867','16870','16882','16883','16891','16906','16909','16912','16913','16919','16922','16925','16926','16945','16947','16949','16967','16978','16981','16987','16990','16998','17001','17011','17012','17022','17024','17025','17028','17038','17040','17041','17042','17048','17050','17056','17061','17067','17070','17073','17093','17094','17105','17107','17110','17112','17114','17118','17127','17135','17149','17156','17165','17168','17171','17175','17187','17188','17193','17194','17197','17207','17209','17211','17218','17219','17221','17222','17226','17229','17240','17247','17251','17253','17276','17283','17292','17295','17302','17304','17315','17324','17326','17329','17331','17336','17347','17351','17353','17362','17363','17370','17377','17386','17388','17390','17399','17403','17404','17405','17407','17408','17411','17419','17435','17437','17441','17451','17463','17475','17482','17484','17485','17491','17493','17496','17503','17505','17507','17509','17520','17521','17529','17534','17535','17547','17558','17560','17568','17570','17579','17584','17587','17596','17598','17600','17601','17602','17605','17616','17632','17639','17648','17649','17652','17656','17660','17680','17681','17684','17691','17700','17701','17706','17710','17724','17729','17741','17742','17747','17750','17757','17762','17774','17775','17782','17786','17790','17804','17813','17830','17831','17832','17833','17835','17837','17842','17843','17845','17846','17847','17851','17854','17858','17861','17863','17866','17887','17897','17914','17919','17921','17922','17933','17941','17950','17961','17968','17974','17983','17988','17989','17998','17999','18000','18006','18019','18025','18035','18036','18049','18050','18058','18069','18077','18078','18092','18098','18103','18105','18114','18118','18119','18125','18127','18136','18138','18144','18149','18153','18158','18163','18166','18176','18181','18184','18192','18196','18209','18228','18229','18235','18236','18246','18269','18272','18283','18288','18290','18293','18295','18312','18326','18332','18335','18337','18343','18345','18353','18358','18364','18380','18382','18396','18402','18403','18417','18423','18427','18432','18435','18441','18454','18457','18461','18481','18488','18489','18494','18495','18502','18506','18518','18535','18536','18549','18554','18559','18595','18596','18612','18623','18625','18628','18629','18634','18637','18642','18645','18656','18662','18664','18673','18687','18693','18702','18715','18716','18719','18720','18725','18730','18742','18743','18746','18748','18755','18757','18772','18775','18776','18781','18787','18788','18790','18797','18809','18811','18813','18816','18823','18825','18851','18858','18871','18872','18875','18891','18903','18906','18907','18908','18910','18913','18915','18920','18937','18941','18942','18943','18946','18948','18949','18954','18957','18958','18962','18964','18968','18976','18981','18988','18990','18996','19005','19014','19019','19023','19031','19037','19040','19042','19058','19068','19070','19074','19079','19086','19091','19094','19095','19105','19110','19112','19115','19121','19122','19123','19136','19145','19157','19165','19169','19171','19176','19181','19186','19189','19194','19197','19199','19207','19208','19214','19223','19225','19228','19237','19249','19252','19255','19264','19268','19269','19270','19274','19295','19301','19307','19308','19314','19317','19318','19321','19323','19324','19335','19337','19339','19343','19348','19349','19353','19358','19364','19371','19382','19384','19385','19395','19398','19402','19405','19422','19430','19447','19448','19453','19454','19456','19465','19466','19476','19478','19484','19486','19488','19490','19501','19506','19514','19519','19521','19522','19527','19539','19540','19553','19555','19557','19564','19577','19579','19580','19590','19604','19612','19614','19623','19631','19634','19642','19648','19651','19654','19655','19656','19668','19677','19682','19686','19695','19721','19724','19730','19749','19751','19753','19755','19759','19762','19766','19767','19768','19772','19778','19791','19807','19812','19818','19829','19836','19838','19843','19847','19848','19850','19852','19853','19854','19858','19861','19868','19870','19878','19884','19910','19914','19918','19921','19922','19925','19928','19942','19943','19947','19950','19959','19971','19977','19981','19985','19986','19994','20000','20003','20007','20008','20015','20028','20029','20041','20056','20063','20069','20075','20078','20083','20085','20089','20091','20098','20105','20128','20129','20143','20146','20153','20154','20156','20159','20170','20180','20181','20182','20183','20188','20189','20195','20200','20204','20209','20216','20218','20221','20224','20229','20233','20234','20237','20239','20241','20253','20256','20260','20263','20264','20265','20268','20271','20274','20289','20290','20291','20304','20306','20307','20308','20311','20317','20324','20339','20348','20350','20357','20363','20369','20370','20376','20379','20387','20388','20403','20404','20407','20413','20415','20425','20433','20437','20440','20442','20443','20444','20446','20448','20450','20458','20464','20481','20489','20495','20496','20511','20512','20513','20514','20517','20522','20534','20535','20540','20541','20550','20555','20556','20558','20561','20569','20570','20573','20582','20613','20614','20623','20631','20637','20643','20647','20669','20686','20695','20696','20705','20707','20716','20718','20724','20728','20729','20736','20738','20742','20748','20761','20779','20782','20785','20793','20812','20814','20840','20846','20848','20853','20857','20872','20875','20880','20881','20885','20891','20899','20914','20917','20924','20937','20943','20944','20947','20959','20970','20974','20982','20984','20985','20986','21003','21006','21013','21028','21032','21036','21047','21054','21056','21057','21058','21079','21087','21094','21097','21102','21111','21113','21118','21120','21131','21138','21153','21154','21167','21168','21170','21172','21186','21187','21191','21202','21213','21216','21217','21220','21227','21238','21241','21247','21249','21271','21281','21290','21300','21304','21306','21312','21316','21318','21320','21328','21334','21337','21338','21348','21350','21352','21356','21399','21403','21423','21424','21435','21441','21449','21455','21463','21478','21481','21482','21486','21487','21491','21494','21509','21510','21512','21518','21521','21523','21529','21530','21532','21533','21535','21537','21549','21577','21578','21579','21583','21587','21598','21604','21613','21623','21632','21641','21643','21652','21655','21656','21659','21671','21673','21674','21683','21684','21690','21697','21713','21716','21721','21725','21727','21733','21734','21735','21737','21745','21746','21751','21753','21758','21775','21779','21788','21789','21793','21795','21800','21809','21813','21814','21826','21831','21850','21858','21862','21869','21873','21875')
OR "id" IN ('21877','21880','21886','21892','21893','21896','21898','21900','21903','21917','21919','21923','21926','21934','21936','21938','21940','21950','21952','21961','21968','21972','21978','21985','21994','22002','22008','22009','22011','22014','22015','22017','22019','22026','22032','22045','22065','22067','22079','22088','22096','22105','22107','22109','22111','22116','22123','22136','22146','22150','22161','22176','22184','22196','22201','22209','22212','22215','22217','22223','22224','22229','22232','22234','22235','22236','22249','22252','22255','22259','22262','22268','22269','22272','22276','22278','22292','22308','22310','22312','22315','22316','22326','22338','22340','22341','22342','22347','22351','22368','22374','22386','22389','22393','22397','22399','22400','22412','22414','22421','22426','22441','22442','22443','22446','22449','22465','22467','22490','22492','22494','22497','22499','22506','22508','22512','22516','22519','22522','22527','22548','22552','22554','22559','22569','22574','22575','22576','22581','22583','22586','22593','22604','22609','22610','22617','22623','22625','22633','22634','22637','22638','22640','22642','22645','22647','22651','22661','22662','22665','22666','22677','22678','22681','22682','22683','22685','22694','22695','22701','22702','22708','22713','22724','22726','22729','22731','22741','22745','22747','22748','22761','22782','22784','22795','22796','22798','22800','22804','22823','22833','22835','22844','22847','22850','22854','22857','22858','22864','22872','22875','22883','22891','22902','22904','22911','22934','22954','22970','22972','22974','22983','22993','23007','23009','23012','23013','23017','23023','23037','23046','23047','23048','23049','23061','23072','23083','23091','23109','23113','23114','23115','23116','23125','23127','23128','23133','23140','23143','23145','23147','23154','23160','23173','23180','23182','23186','23187','23204','23207','23211','23215','23217','23223','23224','23239','23257','23266','23268','23275','23277','23282','23287','23288','23289','23290','23301','23302','23306','23314','23315','23319','23322','23331','23336','23341','23344','23345','23348','23350','23354','23355','23365','23368','23369','23371','23372','23375','23381','23387','23394','23395','23398','23408','23415','23435','23438','23448','23453','23454','23462','23465','23466','23478','23481','23486','23490','23491','23498','23516','23519','23528','23536','23537','23541','23544','23549','23550','23553','23554','23555','23557','23560','23568','23569','23570','23578','23587','23588','23595','23597','23602','23605','23613','23615','23619','23620','23626','23627','23631','23638','23648','23654','23655','23658','23665','23668','23680','23700','23707','23711','23718','23722','23723','23725','23727','23731','23734','23740','23747','23759','23764','23766','23784','23786','23790','23794','23802','23811','23814','23819','23821','23827','23830','23834','23843','23846','23861','23863','23865','23867','23870','23875','23896','23898','23899','23910','23911','23912','23920','23938','23939','23946','23949','23971','23972','23975','23977','23981','23984','23987','23997','24002','24003','24009','24012','24023','24024','24031','24034','24043','24048','24051','24056','24062','24070','24074','24077','24079','24091','24094','24095','24109','24110','24113','24116','24122','24125','24128','24129','24136','24141','24148','24150','24152','24160','24161','24162','24163','24166','24170','24171','24172','24175','24179','24181','24183','24196','24210','24211','24225','24232','24241','24244','24245','24249','24250','24258','24262','24267','24270','24272','24274','24279','24295','24303','24304','24313','24320','24321','24326','24328','24332','24335','24340','24347','24349','24354','24355','24356','24358','24362','24365','24367','24373','24374','24377','24386','24389','24405','24407','24426','24430','24432','24441','24445','24447','24448','24473','24479','24485','24486','24490','24495','24496','24506','24512','24514','24516','24526','24536','24540','24544','24546','24565','24569','24576','24578','24582','24583','24584','24585','24587','24592','24595','24599','24600','24603','24608','24618','24624','24625','24626','24633','24639','24641','24645','24649','24665','24668','24673','24678','24679','24687','24689','24695','24696','24699','24705','24708','24711','24714','24715','24716','24719','24720','24721','24747','24751','24755','24780','24784','24787','24789','24792','24797','24817','24824','24825','24826','24827','24828','24837','24845','24858','24869','24875','24892','24896','24899','24907','24908','24909','24910','24911','24913','24914','24916','24921','24933','24935','24953','24954','24955','24958','24965','24968','24994','25002','25012','25014','25016','25021','25028','25032','25051','25054','25056','25057','25061','25076','25085','25089','25091','25092','25097','25098','25107','25112','25114','25116','25117','25125','25128','25133','25137','25142','25144','25146','25148','25159','25160','25166','25167','25170','25180','25181','25185','25186','25197','25198','25203','25204','25211','25227','25229','25232','25235','25239','25242','25244','25245','25259','25261','25263','25268','25272','25282','25284','25289','25290','25291','25294','25297','25300','25303','25306','25322','25323','25326','25332','25333','25337','25339','25349','25351','25352','25354','25358','25360','25362','25394','25395','25398','25401','25402','25403','25408','25409','25416','25429','25435','25450','25451','25452','25458','25459','25486','25491','25495','25496','25503','25505','25508','25513','25514','25519','25520','25522','25524','25526','25528','25530','25534','25535','25544','25556','25558','25560','25563','25571','25572','25578','25581','25586','25595','25598','25599','25600','25601','25617','25622','25631','25638','25640','25641','25644','25648','25649','25650','25652','25654','25660','25669','25673','25676','25699','25700','25701','25705','25708','25721','25723','25730','25735','25739','25745','25755','25765','25770','25773','25777','25782','25797','25800','25803','25820','25825','25829','25830','25835','25848','25856','25858','25859','25861','25869','25875','25881','25885','25890','25891','25896','25897','25899','25911','25913','25921','25922','25923','25925','25926','25932','25934','25940','25942','25946','25954','25959','25960','25971','25983','25985','26012','26015','26018','26024','26034','26041','26049','26053','26055','26058','26062','26074','26079','26090','26098','26118','26123','26141','26154','26155','26156','26159','26163','26166','26182','26184','26185','26187','26190','26198','26205','26212','26217','26228','26229','26230','26232','26237','26239','26243','26252','26253','26254','26255','26257','26263','26264','26265','26272','26273','26284','26291','26297','26324','26335','26338','26346','26352','26361','26371','26375','26376','26379','26380','26384','26391','26394','26395','26403','26404','26412','26420','26425','26432','26434','26436','26438','26444','26447','26449','26472','26478','26481','26497','26498','26500','26501','26508','26513','26514','26521','26523','26524','26525','26533','26536','26549','26555','26558','26560','26583','26585','26586','26598','26613','26617','26623','26633','26649','26652','26675','26676','26678','26680','26686','26692','26694','26696','26700','26703','26706','26710','26712','26716','26717','26718','26720','26721','26724','26728','26730','26733','26746','26754','26758','26759','26766','26767','26769','26781','26790','26797','26802','26815','26818','26824','26830','26837','26842','26856','26858','26864','26872','26874','26875','26876','26882','26883','26885','26887','26889','26894','26895','26930','26937','26939','26945','26960','26976','26979','26980','26983','26985','26990','27002','27011','27012','27014','27034','27036','27037','27046','27048','27053','27058','27064','27088','27094','27106','27111','27118','27121','27122','27127','27131','27133','27137','27142','27144','27145','27146','27148','27150','27152','27153','27154','27158','27165','27166','27172','27173','27175','27179','27189','27194','27197','27203','27206','27225','27229','27242','27246','27256','27272','27274','27286','27288','27297','27303','27313','27316','27317','27319','27322','27323','27324','27325','27327','27330','27334','27354','27359','27365','27367','27381','27382','27383','27388','27395','27396','27400','27407','27408','27411','27415','27422','27428','27429','27437','27442','27447','27453','27455','27457','27467','27470','27479','27487','27489','27490','27499','27506','27511','27513','27516','27517','27521','27525','27534','27539','27546','27549','27554','27555','27558','27560','27566','27573','27574','27582','27589','27593','27595','27601','27607','27612','27623','27626','27630','27631','27637','27638','27641','27642','27644','27645','27646','27653','27655','27662','27663','27681','27684','27693','27696','27698','27707','27708','27711','27715','27719','27722','27724','27728','27729','27739','27750','27756','27768','27769','27773','27777','27785','27791','27800','27803','27804','27808','27809','27810','27813','27819','27821','27824','27830','27844','27845','27846','27853','27857','27870','27872','27882','27888','27891','27900','27907','27908','27914','27915','27917','27925','27927','27930','27932','27933','27935','27936','27937','27939','27940','27941','27943','27949','27955','27960','27962','27966','27969','27976','27978','27986','28009','28013','28017','28026','28028','28030','28032','28033','28036','28041','28044','28045','28047','28051','28058','28063','28064','28066','28068','28069','28070','28073','28083','28085','28090','28094','28097','28100','28109','28111','28118','28119','28120','28132','28138','28142','28143','28147','28158','28162','28164','28169','28174','28175','28181','28186','28189','28190','28192','28195','28201','28214','28224','28226','28227','28231','28245','28251','28258','28262','28270','28274','28284','28290','28292','28298','28307','28323','28327','28330','28337','28339','28340','28346','28375','28376','28384','28386','28389','28394','28395','28398','28414','28415','28421','28424','28434','28444','28455','28464','28473','28476','28479','28481','28483','28484','28485','28490','28491','28494','28508','28509','28523','28524','28526','28545','28548','28549','28556','28558','28568','28572','28578','28579','28582','28590','28591','28596','28600','28603','28613','28616','28618','28620','28623','28634','28635','28640','28641','28643','28651','28659','28660','28661','28665','28668','28669','28680','28686','28693','28694','28695','28700','28701','28703','28704','28711','28712','28720','28724','28736','28740','28741','28742','28746','28747','28751','28756','28758','28767','28769','28773','28775','28777','28778','28791','28808','28817','28819','28822','28823','28831','28835','28841','28845','28847','28850','28852','28856','28862','28865','28867','28869','28872','28880','28897','28899','28901','28907','28908','28913','28914','28915','28923','28926','28934','28939','28940','28945','28947','28948','28949','28964','28967','28972','28987','28990','29002','29005','29012','29018','29026','29033','29035','29038','29039','29040','29054','29058','29065','29069','29070','29079','29083','29090','29095','29108','29109','29112','29115','29120','29125','29127','29136','29139','29141','29143','29145','29146','29157','29162','29163','29178','29190','29193','29200','29207','29208','29212','29222','29223','29227','29229','29235','29236','29238','29242','29250','29252','29260','29266','29271','29273','29281','29282','29289','29295','29296','29301','29305','29306','29308','29310','29314','29316','29323','29329','29332','29335','29336','29338','29344','29346','29347','29351','29352','29356','29360','29364','29369','29370','29375','29376','29382','29391','29394','29406','29407','29410','29423','29437','29441','29444','29446','29449','29453','29454','29468','29469','29471','29474','29477','29479','29480','29481','29487','29504','29510','29516','29522','29527','29537','29538','29539','29543','29552','29554','29555','29556','29562','29569','29571','29575','29576','29579','29587','29592','29594','29595','29615','29622','29623','29624','29625','29630','29631','29632','29635','29640','29642','29647','29648','29650','29659','29663','29671','29675','29684','29693','29694','29700','29701','29706','29722','29729','29731','29732','29735','29740','29751','29757','29759','29761','29763','29769','29770','29771','29779','29780','29783','29785','29787','29788','29793','29794','29795','29797','29808','29811','29813','29831','29833','29839','29842','29847','29848','29851','29866','29867','29870','29877','29881','29883','29884','29893','29898','29905','29908','29911','29914','29916','29918','29920','29926','29939','29953','29956','29965','29978','29985','29992','29997','30009','30011','30017','30026','30027','30029','30031','30034','30040','30044','30045','30047','30048','30054','30063','30064','30068','30071','30074','30077','30079','30081','30096','30098','30101','30104','30111','30116','30129','30131','30141','30147','30156','30160','30162','30169','30171','30175','30178','30185','30186','30191','30192','30193','30198','30201','30203','30204','30209','30220','30222','30233','30239','30246','30248','30249','30255','30257','30258','30260','30269','30271','30274','30279','30280','30281','30283','30287','30288','30296','30300','30308','30309','30324','30328','30331','30333','30335','30339','30341','30343','30344','30346','30348','30352','30356','30358','30362','30372','30375','30378','30379','30388','30394','30400','30404','30422','30435','30440','30445','30447','30449','30458','30462','30474','30480','30488','30489','30500','30501','30503','30504','30506','30507','30509','30516','30521','30524','30528','30529','30538','30540','30548','30549','30558','30560','30562','30575','30583','30587','30591','30595','30596','30598','30605','30606','30609','30610','30611','30613','30618','30627','30628','30629','30635','30641','30645','30646','30659','30660','30669','30670','30680','30682','30683','30690','30692','30696','30697','30701','30703','30704','30708','30715','30717','30733','30740','30749','30751','30754','30760','30762','30765','30766','30768','30770','30772','30777','30784','30787','30792','30799','30807','30808','30811','30815','30817','30818','30822','30833','30836','30837','30852','30853','30854','30864','30870','30873','30881','30883','30885','30888','30890','30896','30904','30905','30908','30909','30916','30920','30925','30926','30927','30935','30936','30943','30955','30956','30962','30971','30974','30975','30979','30981','30982','30983','30988','30989','31006','31010','31022','31025','31032','31037','31038','31042','31052','31053','31056','31061','31064','31066','31075','31086','31091','31094','31097','31098','31102','31112','31120','31121','31125','31133','31137','31158','31165','31174','31177','31183','31186','31194','31195','31196','31201','31204','31207','31213','31214','31218','31220','31221','31226','31229','31231','31235','31238','31245','31249','31252','31253','31259','31260','31269','31277','31279','31280','31285','31286','31288','31289','31295','31297','31298','31316','31327','31328','31336','31343','31349','31355','31359','31364','31365','31368','31371','31375','31381','31385','31387','31392','31393','31398','31400','31402','31406','31413','31431','31437','31441','31447','31453','31458','31463','31473','31493','31494','31496','31497','31498','31501','31504','31507','31510','31520','31521','31525','31526','31537','31544','31545','31547','31551','31554','31558','31561','31562','31568','31575','31579','31580','31582','31583','31585','31590','31608','31609','31620','31621','31622','31626','31628','31629','31630','31633','31640','31641','31643','31646','31650','31653','31663','31668','31684','31689','31696','31701','31704','31715','31728','31729','31731','31735','31739','31741','31742','31744','31745','31747','31754','31756','31762','31769','31770','31773','31774','31776','31777','31787','31790','31795','31803','31806','31817','31818','31824','31825','31826','31835','31840','31842','31844','31847','31850','31851','31860','31862','31871','31872','31888','31897','31911','31921','31923','31933','31935','31946','31949','31951','31956','31961','31975','31977','31983','31984','31987','31991','32001','32006','32014','32022','32025','32033','32037','32038','32045','32053','32060','32065','32067','32071','32072','32076','32077','32081','32082','32088','32092','32100','32102','32103','32109','32113','32118','32123','32128','32132','32134','32135','32138','32140','32142','32143','32146','32150','32151','32153','32157','32160','32161','32162','32166','32187','32191','32192','32193','32195','32202','32205','32206','32211','32213','32215','32217','32223','32238','32240','32242','32243','32247','32250','32252','32276','32280','32282','32283','32286','32295','32301','32304','32310','32311','32312','32323','32324','32326','32336','32343','32346','32348','32351','32356','32360','32361','32362','32365','32368','32372','32374','32376','32382','32392','32399','32402','32416','32417','32418','32421','32426','32438','32450','32455','32456','32457','32459','32461','32469','32470','32479','32480','32485','32489','32494','32501','32503','32511','32512','32518','32519','32520','32523','32525','32529','32536','32538','32542','32544','32551','32580','32585','32587','32592','32595','32596','32604','32616','32618','32622','32623','32624','32626','32629','32633','32636','32643','32647','32650','32654','32662','32683','32686','32690','32699','32701','32705','32707','32724','32728','32733','32735','32749','32772','32777','32786','32789','32795','32796','32800','32815','32818','32819','32823','32825','32829','32830','32834','32835','32840','32841','32855','32857','32865','32868','32869','32871','32873','32880','32883','32889','32891','32892','32893','32894','32900','32931','32939','32945','32946','32951','32958','32964','32974','32975','32976','32977','32980','32982','32985','33001','33002','33003','33008','33009','33012','33014','33015','33019','33027','33031','33033','33042','33044','33045','33049','33055','33069','33083','33089','33093','33094','33109','33115','33116','33124','33125','33126','33135','33144','33149','33165','33173','33185','33210','33229','33234','33235','33240','33264','33271','33278','33288','33289','33291','33295','33303','33304','33305','33333','33335','33336','33346','33355','33376','33384')

And this is the result :-)






dismo pwdSample and ssb for a large number of species distribution records

For my MarineSPEED dataset of species I'm trying to create non-random cross-validation datasets. In order to do this I was looking at the pwdSample and ssb functions from the dismo package. pwdSample calculates a pair-wise distance sampling and ssb calculates the spatial sorting bias. More information about these functions can be found in the excellent paper by Robert Hijmans (2012): "Cross-validation of species distribution models: removing spatial sorting bias and calibration with a null model".

Problem is that both functions calculate a distance matrix between two sets of points which starts to fail when the number of points is (very) large. To fix this I re-implemented the functions replacing the matrix calculation and subsequent row minimum finding with the same functionality but using a divide and conquer strategy by calculating distance matrices on subsets, taking the min distance and then taking the min distances of these min distances to get row based minima.

In other words I replaced:

fromd <- apply(distfun(fixed, reference), 1, min)

with:

mindist <- function(distfun, a, b) {
  partition_count <- (1 %/% (100 / NROW(b))) + 1
  parts <- dismo::kfold(x=b, k=partition_count)
  r <- c()
  for(i in 1:partition_count) {
    mind <- apply(distfun(a, b[parts==i,]), 1, min)
    r <- cbind(r, mind)
  }
  apply(r, 1, min)
}
  
fromd <- mindist(distfun, fixed, reference)

The full pwdSample function then becomes:

pwdSample_robust <- function(fixed, sample, reference, tr = 0.33, nearest= TRUE, n=1, lonlat = TRUE, warn = TRUE) {
  ## DIVIDE reference, calculate distance matrix, get min, COMBINE: take min of the min, do rest of the pwdSample logic
  distHaversine <- function(p1, p2) {
    r <- 6378137
    toRad <- pi/180
    p1 <- p1 * toRad
    p2 <- p2 * toRad
    p <- cbind(p1[, 1], p1[, 2], p2[, 1], p2[, 2])
    dLat <- (p[, 4] - p[, 2])
    dLon <- (p[, 3] - p[, 1])
    a <- sin(dLat/2) * sin(dLat/2) + cos(p[, 2]) * cos(p[, 
                                                         4]) * sin(dLon/2) * sin(dLon/2)
    dist <- 2 * atan2(sqrt(a), sqrt(1 - a)) * r
    as.vector(dist)
  }
  distGeo <- function(x, y) {
    n <- nrow(x)
    m <- nrow(y)
    dm <- matrix(ncol = m, nrow = n)
    for (i in 1:n) {
      dm[i, ] <- distHaversine(x[i, , drop = FALSE], y)
    }
    return(dm)
  }
  distPlane <- function(x, y) {
    dfun <- function(x, y) {
      sqrt((x[, 1] - y[, 1])^2 + (x[, 2] - y[, 2])^2)
    }
    n = nrow(x)
    m = nrow(y)
    dm = matrix(ncol = m, nrow = n)
    for (i in 1:n) {
      dm[i, ] = dfun(x[i, , drop = FALSE], y)
    }
    return(dm)
  }
  if (lonlat) {
    distfun <- distGeo
  }
  else {
    distfun <- distPlane
  }
  stopifnot(tr > 0)
  n <- round(n)
  stopifnot(n >= 1)
  if (inherits(fixed, "SpatialPoints")) 
    fixed <- coordinates(fixed)
  if (inherits(sample, "SpatialPoints")) 
    sample <- coordinates(sample)
  if (inherits(reference, "SpatialPoints")) 
    reference <- coordinates(reference)
  fixed <- as.matrix(fixed)[, 1:2]
  sample <- as.matrix(sample)[, 1:2]
  reference <- as.matrix(reference)[, 1:2]
  if (warn) {
    if (nrow(sample) < nrow(fixed)) {
      warning("nrow(sample) < nrow(fixed)")
    }
  }
  
  mindist <- function(distfun, a, b) {
    partition_count <- (1 %/% (100 / NROW(b))) + 1
    parts <- dismo::kfold(x=b, k=partition_count)
    r <- c()
    for(i in 1:partition_count) {
      mind <- apply(distfun(a, b[parts==i,]), 1, min)
      r <- cbind(r, mind)
    }
    apply(r, 1, min)
  }
  
  fromd <- mindist(distfun, fixed, reference) ##apply(distfun(fixed, reference), 1, min)
  tod <- mindist(distfun, sample, reference) ##apply(distfun(sample, reference), 1, min)
  ngb <- matrix(NA, nrow = length(fromd), ncol = n)
  iter <- sample(1:nrow(fixed))
  for (j in 1:n) {
    for (i in iter) {
      d <- abs(tod - fromd[i])
      if (min(d) < (tr * fromd[i])) {
        if (nearest) {
          x <- which.min(d)
        }
        else {
          x <- sample(which(d < (tr * fromd[i])), size = 1)
        }
        ngb[i, j] <- x
        tod[x] <- Inf
      }
    }
  }
  return(ngb)
}

and the ssb function then looks like this:


ssb <- function(p, a, reference, lonlat = TRUE, avg = TRUE) {
  distHaversine <- function(p1, p2) {
    r <- 6378137
    toRad <- pi/180
    p1 <- p1 * toRad
    p2 <- p2 * toRad
    p <- cbind(p1[, 1], p1[, 2], p2[, 1], p2[, 2])
    dLat <- (p[, 4] - p[, 2])
    dLon <- (p[, 3] - p[, 1])
    a <- sin(dLat/2) * sin(dLat/2) + cos(p[, 2]) * cos(p[, 
                                                         4]) * sin(dLon/2) * sin(dLon/2)
    dist <- 2 * atan2(sqrt(a), sqrt(1 - a)) * r
    as.vector(dist)
  }
  distGeo <- function(x, y) {
    n <- nrow(x)
    m <- nrow(y)
    dm <- matrix(ncol = m, nrow = n)
    for (i in 1:n) {
      dm[i, ] <- distHaversine(x[i, , drop = FALSE], y)
    }
    return(dm)
  }
  distPlane <- function(x, y) {
    dfun <- function(x, y) {
      sqrt((x[, 1] - y[, 1])^2 + (x[, 2] - y[, 2])^2)
    }
    n = nrow(x)
    m = nrow(y)
    dm = matrix(ncol = m, nrow = n)
    for (i in 1:n) {
      dm[i, ] = dfun(x[i, , drop = FALSE], y)
    }
    return(dm)
  }
  if (lonlat) {
    distfun <- distGeo
  }
  else {
    distfun <- distPlane
  }
  if (inherits(p, "SpatialPoints")) 
    p <- coordinates(p)
  if (inherits(a, "SpatialPoints")) 
    a <- coordinates(a)
  if (inherits(reference, "SpatialPoints")) 
    reference <- coordinates(reference)
  p <- as.matrix(p)[, 1:2]
  a <- as.matrix(a)[, 1:2]
  reference <- as.matrix(reference)[, 1:2]
  
  mindist <- function(distfun, a, b) {
    partition_count <- (1 %/% (1000 / NROW(b))) + 1
    parts <- dismo::kfold(x=b, k=partition_count)
    r <- c()
    for(i in 1:partition_count) {
      mind <- apply(distfun(a, b[parts==i,]), 1, min)
      r <- cbind(r, mind)
    }
    apply(r, 1, min)
  }
  pd <- mindist(distfun, p, reference) #   pd <- apply(distfun(p, reference), 1, min)
  ad <- mindist(distfun, a, reference) #   ad <- apply(distfun(a, reference), 1, min)
  if (avg) {
    res <- cbind(mean(pd), mean(ad))
    colnames(res) <- c("p", "a")
    return(res)
  }
  else {
    return(list(pd, ad))
  }
}